Record the SSM integrated configuration file

Web configuration during SSM integration:

  1. <url-pattern> / </ url-pattern>: will not match * .jsp, ie: * .jsp will not enter Spring's DispatcherServlet class.

  2. <url-pattern> / * </ url-pattern>: will match path-type and suffix-type url (including / login, .jsp, .js and * .html, etc.), visit .jsp, and return to jsp view When entering the DispatcherServlet class of spring again, it caused a 404 error because it could not find the corresponding controller.

  3. Because springmvc uses the DispatcherServlet class to handle front-end requests, it is configured as <url-pattern> / </ url-pattern> to pass the path-type url to springMVC for processing

    For example, Chinese garbled processing and shiro security authentication processing need to handle all urls, so the configuration is <url-pattern> / * </ url-pattern>

-

springmvc.xml

<!-- 加载属性文件 -->
	<context:property-placeholder location="classpath:resource/resource.properties"/>
	<!-- 配置注解驱动 -->
	<mvc:annotation-driven />
	<!-- 视图解析器 -->
	<bean
		class="org.springframework.web.servlet.view.InternalResourceViewResolver">
		<property name="prefix" value="/WEB-INF/jsp/" />
		<property name="suffix" value=".jsp" />
	</bean>
	<!-- 配置包扫描器,扫描@Controller注解的类 -->
	<context:component-scan base-package="com.taotao.controller"/>
	<!-- 配置资源映射 /**表示当前目录和所有子目录,/*表示当前目录-->
	<mvc:resources location="/css/" mapping="/css/**"/>
	<mvc:resources location="/js/" mapping="/js/**"/>
	<!-- 多媒体解析器 -->
	<!-- 配置文件上传解析器 -->
	<bean id="multipartResolver class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
		<!-- 设定默认编码 -->
		<property name="defaultEncoding" value="UTF-8"></property>
		<!-- 设定文件上传的最大值5MB,5*1024*1024 -->
		<property name="maxUploadSize" value="5242880"></property>
	</bean>
Published 8 original articles · won 3 · views 186

Guess you like

Origin blog.csdn.net/qq_42641075/article/details/105415903