ActionForm的接收值问题

来源:百度知道 编辑:UC知道 时间:2024/06/05 18:25:22
本人初学 刚刚学些struts框架
我只做一个登陆 需要用户名和密码 jsp代码为
<form action="user.do" method="post">
<table width="100%">
<tr>
<th>用户名</th>
<input type="hidden" name="Method" value="isUser">
<td><input type="text" name="user.uname" size="10" maxlength="20" /></td>
</tr>
<tr>
<th>密码</th>
<td><input type="password" name="user.upass" size="10" maxlength="20" /></td>
</tr>
<tr>
<td> </td>
<td><input type="image" src="images/login/login_button.jpg" width="73" height="25"></td>
</tr>

给你纠正几个问题吧
1.你的Form 应该写为Struts标签的
<html:form action="" method="">
</html:form>
2.变量可别user.uname
没这么起名的 不带加点的 太不规范了
userName password 足够
3.ActionForm 不需要写什么reset 感觉没什么意义
就写private String userName;
private String password;
然后是getter和setter方法 Form要继承
只要你的JSP能进action 就没问题了 准能接到参数。