SpringMVC支持以下Servlet方法:
HttpServletRequest
HttpServletResponse
HttpSession
Writer
Reader
Locale
InputStream
OutputStream
java.security.Principal
控制器参考代码:
package com.tiekui.springmvc.handlers; import java.io.IOException;
import java.io.Writer; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping; @Controller
public class ServletApiTest { @RequestMapping("testServerletApi")
public void testServerletApi(HttpServletRequest request,HttpServletResponse response,Writer writer) {
System.out.println("request:" + request + ",response " + response);
try {
writer.write("Hello,This is a servlet writer response");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
视图代码:
<a href="testServerletApi">Test Servlet Api Video 13</a>