I'm successfully able to integrate Spring and Spring4GWT. Everything is working fine.
The only problem I'm facing is How do I get HttpServletRequestObject in the @service class?
Some of the configuration and code
<servlet>
<servlet-name>test</servlet-name>
<servlet-class>org.spring4gwt.server.SpringGwtRemoteServiceServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>test</servlet-name>
<url-pattern>/ui/test/*</url-pattern>
</servlet-mapping>
public class LoginServiceImpl implements ILoginService {
private IUserService userService;
public LoginServiceImpl(IUserService userService) {
super();
this.userService = userService;
}
public boolean isAuthenticUser(String userName, String password) {
// operation
}
}
In LoginServiceImpl I'm not able to get the Servlet object.
I need it here so that I can use it for different purposes.
Any Idea?
Finally I got a solution for it. If someone wants to have access of the HttpServletrequest in the GWT-RPC service then the following can help.
<filter>
<filter-name>springRequestFilter</filter-name>
<filter-class>org.springframework.web.filter.RequestContextFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>springRequestFilter</filter-name>
<url-pattern>/your_pattern/*</url-pattern>
</filter-mapping>
ServletRequestAttributes sra = ((ServletRequestAttributes)RequestContextHolder.currentRequestAttributes());
sra.getRequest();
Hope this is helpful
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With