I would like integrate struts 2 with spring mobile. On Spring official site, http://docs.spring.io/spring-mobile/docs/1.1.1.RELEASE/reference/html/device.html
I have follow instructions to integrate spring mobile on my project. On start up, i have not encounter any problem, but when i try to obtain the currentDevice my object is null, with :
Device currentDevice = DeviceUtils.getCurrentDevice(request);
Have someone tried to integrate spring mobile with struts2 ??
my web.xml:
<filter>
<filter-name>deviceResolverRequestFilter</filter-name>
<filter-class>org.springframework.mobile.device.DeviceResolverRequestFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>deviceResolverRequestFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
Definition of my handler interceptor on applicationContext.xml:
<bean class="org.springframework.mobile.device.DeviceResolverHandlerInterceptor" />
My testClass:
public class AuthenticationAction extends ActionSupport implements
SessionAware, ServletRequestAware {
Log mylog = LogFactory.getLog(AuthenticationAction.class);
// So that we can lookup the current Device
private HttpServletRequest request;
@RequestMapping("/")
public String computeLogin() {
...
Device currentDevice = DeviceUtils.getCurrentDevice(request);
if (currentDevice != null) {
mylog.info("Device type: ");
mylog.info("mobile: " + currentDevice.isMobile());
mylog.info("normal " + currentDevice.isNormal());
mylog.info("tablet " + currentDevice.isTablet());
}
}
public void setSession(Map<String, Object> session) {
this.mySession = session;
}
public void setServletRequest(HttpServletRequest request) {
this.setRequest(request);
}
public HttpServletRequest getRequest() {
return request;
}
public void setRequest(HttpServletRequest request) {
this.request = request;
}
}