SpringMVC对原生Servlet API支持

SpringMVC支持原生Servlet API 作为参数传入映射的方法。具体如下:

private static final String SUCCESS = "success";

@RequestMapping (value = "/servlet/api")
private String testServletAPI (HttpServletRequest req, HttpServletResponse resp, Writer writer) {
        String username = req.getParameter("name");
        ... ...
        Servlet API操作
        ... ... 
    
        return SUCCESS;
}

SpringMVC对原生Servlet API支持类型具体如下:

  • HttpServletRequest
  • HttpServletResponse
  • HttpSession
  • Principal
  • Locale
  • InputStream
  • OutputStream
  • Reader
  • Writer

你可能感兴趣的:(SpringMVC对原生Servlet API支持)