验证码是通过struts2的Action来生成的,
一旦通过DWR 框架,那么dwr2.0中 好像还是不太支持struts2,
请问该如何处理呢? 才能在userService.checkLogin(User user,String verifyCode) 中获取到验证码?
我的dwr配置是通过Spring的注入bean来设置的
<convert converter="bean" match="com.squall.oa.model.User" javascript="myUser"/>
<create creator="spring" javascript="userService">
<param name="beanName" value="userService"/>
<include method="checkLogin"/>
</create>
[b]问题补充:[/b]
TO:lovewhzlq (资深架构师)
感谢您的答复!!
那么在dwr中 为什么必须要通过
org.directwebremoting.WebContextFactory.get().getHttpServletRequest().getSession();
去获得Session呢?
能告诉下小弟原理是为什么吗?
[b]问题补充:[/b]
问题还是没解决
在UserService层中 调用
org.directwebremoting.WebContextFactory.get().getHttpServletRequest().getSession();
出错
java.lang.NullPointerException
at com.squall.oa.service.impl.UserServiceImpl.checkLogin(UserServiceImpl.java:84)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:307)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy11.checkLogin(Unknown Source)
at com.squall.oa.action.UserAction.checkLogin(UserAction.java:41)
at com.squall.oa.action.UserAction.execute(UserAction.java:34)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:404)
at com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:267)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:229)
at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:221)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86)
at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)
[b]问题补充:[/b]
谢谢,可是问题还是没解决,仍然报错~
我郁闷死了,难道s2sh 这样的架构,整合dwr这么费劲么?
[b]问题补充:[/b]
TO:jansel (高级程序员)
我在测试struts2整合dwr2.0框架、
郁闷了半天,都看遍了,还是报告
'DWRActionUtil' 未定义
我都看了~~
网站目录下也有 DWRActionUtil.js
[b]问题补充:[/b]
TO:jansel (高级程序员)
我已经整合成功了!
但是 现在就差传参数了!~~
我前台js是这么写的,
你看行么?
var username,password,result;
username = $("uname").value;
password = $("upass").value;
var myUser = {};
myUser.u_name = username;
myUser.u_pass = password;
DWRActionUtil.execute({
namespace:'/user',
action:'checkLogin',
executeResult:'false',
params:myUser
}, 'frmLogin', callBackLogin);//frmDwr为表单id
[b]问题补充:[/b]
那您觉得
现在如何设计登录口比较合理?
最主要的是安全、稳定!