1. What can be used
The handler method in MVC can accept parameters of type Servletapi.
2.controller
1 Packagecom.spring.it;2 3 Importjava.io.IOException;4 ImportJava.io.Writer;5 6 Importjavax.servlet.http.HttpServletRequest;7 ImportJavax.servlet.http.HttpServletResponse;8 9 ImportOrg.springframework.stereotype.Controller;Ten Importorg.springframework.web.bind.annotation.RequestMapping; One A @Controller - Public classServletapicontrol { -@RequestMapping ("/helloworld6") the Public voidHello (httpservletrequest request,httpservletresponse response,writer out)throwsException { -System.out.println ("request=" +request); -System.out.println ("response=" +response); -Out.write ("Spring MVC"); + } -}
3.index
1 <%@ Page Language="Java"ContentType="text/html; charset=iso-8859-1"2 pageencoding="iso-8859-1"%>3 <!DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "Http://www.w3.org/TR/html4/loose.dtd ">4 <HTML>5 <Head>6 <Metahttp-equiv= "Content-type"content= "text/html; charset=iso-8859-1">7 <title>Insert Title here</title>8 </Head>9 <Body>Ten <BR> One <ahref= "helloworld6/">Test servlet API</a> A </Body> - </HTML>
4. Effects
5.ps
The origin of writer
Response.getwriter ();
Using the Servlet API as a parameter