<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc https://www.springframework.org/schema/mvc/spring-mvc.xsd">
<!-- 1 配置视图解析器 内部资源解析器-->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<!-- 重要属性,视图的前缀,视图的后缀, 前后的斜杠一定要记得加上,否则容易初问题。-->
<property name="prefix" value="/pages/"/>
<property name="suffix" value=".jsp"/>
</bean>
<!-- 配置包的扫描-->
<context:component-scan base-package="com.sz.controller"/>
<!-- 添加注解驱动-->
<mvc:annotation-driven></mvc:annotation-driven>
<!-- 配置默认的servlet 如果发现没有合适的控制器来处理当前的请求,那么我们就把它交给这个默认的servlet来处理-->
<mvc:default-servlet-handler/>
<!-- 这个bean 取名字,名字固定就叫做multipartResolver-->
<bean class="org.springframework.web.multipart.commons.CommonsMultipartResolver" id="multipartResolver">
<!-- // bytes 1024 * 1024 * 8 限定八兆总大小
下面这个是限定所有文件大小的总合
-->
<property name="maxUploadSize" value="#{1024 * 1024 * 8}"/>
<!-- 限定单个文件最大上传多少-->
<property name="maxUploadSizePerFile" value="#{1024 * 1024 * 2}"/>
<!-- 默认编码处理-->
<property name="defaultEncoding" value="UTF-8"/>
</bean>
<!--静态资源处理-->
<mvc:default-servlet-handler/>
<!--错误解析器-->
<bean class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
<property name="exceptionMappings">
<props>
<prop key="java.lang.NullPointerException">error/404</prop>
</props>
</property>
<property name="defaultErrorView" value="error/405"></property>
</bean>
</beans>
springmvc解析器
最新推荐文章于 2024-04-22 08:50:12 发布