Action页面 package com.lkx.action; import com.opensymphony.xwork2.ActionSupport; import com.opensymphony.xwork2.ModelDriven; import entity.Users; public class RegisterAction extends ActionSupport implements ModelDriven<Users>{ private Users user = new Users(); public Users getUser() { return user; } public Users getModel() { // TODO Auto-generated method stub return user; } public String register() throws Exception{ System.out.println("取到吗-----"+user.getUsername()); return null; } } struts.xml <struts> <package name="lkx" extends="struts-default"> <action name="register" class="com.lkx.action.RegisterAction" method="register"> <interceptor-ref name="modelDriven"></interceptor-ref> <interceptor-ref name="defaultStack"></interceptor-ref> <result name="input">/index.jsp</result> <result name="success">/success.jsp</result> </action> </package> </struts> jsp页面 <s:form action="register" method="post"> <s:textfield name="username" label="用户名"></s:textfield> <s:submit value="注册"></s:submit> Users 类里就是get和set方法了 |
|
<interceptor-ref name=”modelDriven”></interceptor-ref>
没有在action里面看到注入的属性啊 在action里面增加private ModelDriven modelDriven; |
|
不明白,能解释明白一点吗 |
|
struts哪个版本?
|
|
|
|
40分 |
2.0.6的拦截器是model-driven,不是modelDriven。
|
谢谢!根据你说的,搞定了,花了好长时间反复看代码始终找不到原因,谢谢啊! |