ssm integration used to configure web.xml

You do not need to run the web project needs a spring factory class object? needs. When will create more appropriate? Creating than tommcat start time more appropriate.










So spring provides a listener for us to implement the code.
-> <listener> <listener-class> org.springframework.web.context.ContextLoaderListener </ listener-class> </ listener> <-! Spring manually specify the location and name of the main configuration file by default will spring from WEB- load INF directory as the spring applicationContext.xml main configuration file, but generally we do not like the main configuration file into this place , we used to put under the resources directory, so usually manually specify the location and name of the spring main configuration file - -> <context-param> <param-name> the contextConfigLocation </ param-name> <param-value> CLASSPATH: spring.xml </ param-value> </ context-param> ! <- front end of the control spring mvc an effect of: intercepting the request to the corresponding spring mvc process -> <the servlet> <the servlet-name>


















<the servlet-class> org.springframework.web.servlet.DispatcherServlet </ the servlet-class> <-! manually specify the spring mvc master configuration file location and name of the default spring mvc will continue to load [servlet's name] from the WEB-INF -servlet.xml this master configuration file, for example, the current name of the main configuration file should be spring-mvc-servlet.xml. generally, we still hope to spring mvc master configuration file into the resources at hand, so usually manually specify the -> <the init-param> <param-name> the contextConfigLocation </ param-name> <param-value> CLASSPATH: Spring-mvc.xml </ param-value> </ the init-param> </ the servlet> <-Mapping the servlet> <the servlet-name> Spring-MVC </ the servlet-name> <URL-pattern> *. do </ URL-pattern> </ Mapping the servlet-> <filter>


















<filter-name>characterEncodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>characterEncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>

Guess you like

Origin www.cnblogs.com/b6952/p/10939519.html