1、页面适配(自动识别终端设备)
引入依赖
<springframework.mobile.version>1.1.5.RELEASE</springframework.mobile.version>
<dependency>
<groupId>org.springframework.mobile</groupId>
<artifactId>spring-mobile-device</artifactId>
<version>${springframework.mobile.version}</version>
</dependency>
增加web-mobile.xml配置文件
<?xml version="1.0" encoding="GB2312"?>
<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-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
<!-- spring mobile -->
<mvc:interceptors>
<bean class="org.springframework.mobile.device.DeviceResolverHandlerInterceptor" />
<bean class="org.springframework.mobile.device.site.SitePreferenceHandlerInterceptor" />
</mvc:interceptors>
<!--spring 3.0不支持此种方式-->
<!--<mvc:annotation-driven>
<mvc:argument-resolvers>
<bean class="org.springframework.mobile.device.DeviceWebArgumentResolver" />
</mvc:argument-resolvers>
</mvc:annotation-driven>-->
<bean class="org.springframework.mobile.device.view.LiteDeviceDelegatingViewResolver">
<constructor-arg>
<ref bean="viewResolver"/>
</constructor-arg>
<property name="order" value="1"/>
<property name="enableFallback" value="true" />
<property name="mobilePrefix" value="${mobile.view.prefix}" />
<!-- <property name="tabletPrefix" value="tablet/" /> -->
</bean>
</beans>
增加全局变量
## 手机适配前缀文件夹
mobile.view.prefix=mobile/
引入上下文
<servlet>
<servlet-name>jresServlet</servlet-name>
<servlet-class>com.hundsun.jresplus.web.servlet.DispatcherServlet</servlet-class>
<!-- <init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:uc-aop-web-main.xml</param-value>
<param-value>WEB-INF/conf/spring/web/web-main.xml</param-value>
</init-param> -->
<init-param>
<param-name>mobileConfigLocation</param-name>
<param-value>/WEB-INF/conf/spring/web/web-mobile.xml</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>