struts2 action问题

来源:百度知道 编辑:UC知道 时间:2024/06/20 16:53:59
下面是jsp中表单
<form id="form1" name="form1" method="post"action="doLogin.action">
username:<input type="text" name="userModel.username" id="username" size="10"><br><br>
password:<input type="password" name="userModel.password" id="password" size="10"><br><br>
<input type="submit" value="submit"/><input type="reset" value="reset"/>
</form>

struts.xml配置
<action name="doLogin"
class="com.njusc.user.action.UserAction" method="login">
<result name="success">/bm/jsp/bmlist.jsp</result>
<result name="login">/user/jsp/userself.jsp</result>
<result name="error">/user/jsp/userlogin.jsp</result>
</action>

你这么写,首先你的action要继续extends ActionSupport {

在把你的实体写进来

private User user;

然后加上get和set方法。。自然会把对应的值装到对像对应的值中

注意类型