struts2 后台action向前端JSP传递参数的问题
后台有个方法,里面部分代码如下:
System.out.print("alter:"+user.getId()); User temp=userservice.getUserByUserId(user.getId()); System.out.print(temp.getUsername()); ActionContext.getContext().put("temp", temp); return "userAlter";
经过调试,temp对象是有值的,上面的代码也是正确的,但是如果我将 ActionContext.getContext().put("temp", temp);换乘 ActionContext.getContext().put("user", temp);,那么前端就无法显示内容。
前端代码:
信息修改: ${temp.id} ${temp.username }用户名:${user.username } 用户密码:${user.password }
这里面的问题,我不知道是什么原因。我猜应该是Put的键和由spring托管的那个user变量同名,可能spring无法处理之类的。。暂且这么理解吧!