web.xml:
<?
xml
version="1.0" encoding="UTF-8"?>
<
web-app
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<!-- 加载Spring容器配置,配置监听器 -->
<
listener
>
<
listener-class
>org.springframework.web.context.ContextLoaderListener</
listener-class
>
</
listener
>
<!-- 设置Spring容器加载配置文件路径 -->
<
context-param
>
<
param-name
>contextConfigLocation</
param-name
>
<
param-value
>/WEB-INF/config/applicationContext.xml</
param-value
>
</
context-param
>
<
servlet
>
<
servlet-name
>spring</
servlet-name
>
<
servlet-class
>org.springframework.web.servlet.DispatcherServlet</
servlet-class
>
<
init-param
>
<
param-name
>contextConfigLocation</
param-name
>
<
param-value
>/WEB-INF/spring-servlet.xml</
param-value
>
</
init-param
>
<
load-on-startup
>1</
load-on-startup
>
</
servlet
>
<
servlet-mapping
>
<
servlet-name
>spring</
servlet-name
>
<
url-pattern
>/</
url-pattern
>
</
servlet-mapping
>
</
web-app
>
spring-mvc.xml:
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.springframework.org/schema/beans" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:cache="http://www.springframework.org/schema/cache" xmlns:p="http://www.springframework.org/schema/p" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:websocket="http://www.springframework.org/schema/websocket" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd http://www.springframework.org/schema/websocket http://www.springframework.org/schema/websocket/spring-websocket.xsd http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache.xsd"> <!-- 扫描上下文 --> <context:component-scan base-package="com.seawin.webapp.base.controller.pcweb" /> <context:component-scan base-package="com.seawin.webapp.sale.controller.pcweb" /> <context:component-scan base-package="com.seawin.webapp.base.mobileweb" /> <context:component-scan base-package="com.seawin.webapp.freight.controller.pcweb" /> <context:component-scan base-package="com.seawin.webapp.customs.controller.pcweb" /> <context:component-scan base-package="com.seawin.webapp.workflow.controller.pcweb" /> <context:component-scan base-package="com.seawin.webapp.shipping.controller.pcweb" /> <context:component-scan base-package="com.seawin.webapp.air.controller.pcweb" /> <context:component-scan base-package="com.seawin.webapp.logistics.controller.pcweb" /> <context:component-scan base-package="com.seawin.webapp.account.controller.pcweb" /> <!--视图解析器配置 --> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver" p:viewClass="org.springframework.web.servlet.view.JstlView"
p:prefix="/" p:suffix=".html" /> <!--注解 --> <bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping"> </bean> <!--json转换器RequestMappingHandlerAdapter --> <bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter"> <property name="messageConverters"> <list> <bean class="org.springframework.http.converter.ByteArrayHttpMessageConverter"/> <bean class="org.springframework.http.converter.StringHttpMessageConverter"> <property name="supportedMediaTypes"> <list> <value>text/html;charset=UTF-8</value> <value>application/json;charset=UTF-8</value> <value>text/plain;charset=UTF-8</value> </list> </property> </bean>
<bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter"> <property name="supportedMediaTypes"> <list> <value>text/html;charset=UTF-8</value> <value>application/json;charset=UTF-8</value> <value>text/plain;charset=UTF-8</value> </list> </property> </bean> </list> </property> </bean> <!--文件上传--> <bean id="multipartResolver" class="com.seawin.webapp.base.mulipart.MyMultipartResolver"> <!-- url中带有excludeUrls的http请求就不会被multipartResolver先解析 --> <property name="excludeUrls" value="/uploader/uploadFile.do,/saleFile/uploader.do, /freightAttachment/uploadFile.do,/user/uploader.do, /logisticsAttachment/uploader.do,/CustomsDeclareBill/upload.do,/ShippingBill/upload.do" /> <property name="maxUploadSize" value="104857600"></property> <property name="defaultEncoding" value="utf-8"></property> </bean> <!-- 静态文件映射 --> <mvc:resources location="/" mapping="/**/*.html" /> <mvc:resources location="/" mapping="/**/*.js" /> <mvc:resources location="/" mapping="/**/*.css" /> <mvc:resources location="/" mapping="/**/*.png" /> <mvc:resources location="/" mapping="/**/*.gif" /> <!-- 属性文件配置 --> <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="locations"> <list> <value>classpath:/config/deploy/jdbc.properties</value> <value>classpath:/config/deploy/redis.properties</value> <value>classpath:/config/deploy/application.properties</value> <!--要是有多个配置文件,只需在这里继续添加即可 --> </list> </property> </bean> </beans>