Controller(1)

Controller

---------------------------------------------------------------------------

[The role of controller]

1. It is part of C in springmvc, DispatcherServlet + Controller

2. Collect verification request parameters and bind them to the corresponding command object

3. Transfer the command object to the business object, and the business object processes the returned data

4. Return to ModeleAndView

--------------------------------------------------------------------------

[1. Controller interface]

1. There is only one handleRequest method, which is processed by the function of the request and put back into ModeleAndView

-----------------------------------------------------------------------

[2, WebContentGenerator abstract class]

1. It is used to provide browser cache control, request method (post, get, head), whether session is enabled

2. Inherited by AbstractController and WebContentInterceptor, see AbstractController for specific usage

------------------------------------------------------------------------------

[3, AbstractController abstract class]

1. Implement the Controller interface and inherit the WebContentGenerator abstract class

2. Mandatory request method type

<bean id="###" name="/###.do" class="###"> 

<property name="supportedMethods" value="POST"/>

</bean>

---------------------------------------------------------------------

【4、ServletForwardingController】

1. Forward the request received by the Controller to the Servlet

2. Create Servlet, configure Servlet in web.xml, servlet-mapping tag configuration is optional

3. In the sptingmvc configuration file

<bean name="/###.do" class="###>

<property name="servletName" value="web.xml中配置的Servlet"></property>

</bean>

---------------------------------------------------------------------------------

 

 

 

 

------------------------------------------------------------------------

[In-depth understanding of HTTP Session]

http://lavasoft.blog.51cto.com/62575/275589/

[Several methods for Servlet to jump to jsp page]

1. sendRedirect method

 sendRedirect("/a.jsp");

 The page can be jumped to any path, not limited to web applications. The url address changes during the jump process and cannot be passed using request.setAttribute.

2. Forward method

 request.getRequestDispatcher("/a.jsp").forward(request.response);

 The url address remains unchanged, and it can only jump to the page in this web application. You can use the request.setAttibute method

-----------------------------------------------------------------------

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326489945&siteId=291194637