日期:2014-05-17  浏览次数:20744 次

struts 表单提交 action不执行
为什么点击登录button画面出现空白页面,设置断点action不执行。是不是我哪里配置错误了吗?
代码如下:

【index.jsp】
<html:form action="/userAction" method="post" focus="name">
<table height="100%" style="vertical-align: middle;">
<tr>
<td>
<table border="0" class="table1">
<tr height="90">
<td colspan="4"></td>
</tr>
<tr>
<td width="100"></td>
<td align="right">
<font>用户名:</font>
</td>
<td align="right">
<html:text property="name" maxlength="20"
style="border:1px solid #1c5180; width:145px; margin-left:5px; padding-left:5px;" />
</td>
<td width="120"></td>
</tr>
<tr>
<td></td>
<td align="right">
<font>密&nbsp;&nbsp;&nbsp;&nbsp;码:</font>
</td>
<td align="right">
<html:password property="passwd" maxlength="18"
style="border:1px solid #1c5180; width:145px; margin-left:5px; padding-left:5px;" />
</td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td align="right" height="70">
<html:submit styleId="btn" value="登录"
style="width:56px; height:20px;background-color:#4c8dd5;"></html:submit>
</td>
<td></td>
</tr>
<tr height="60">
<td colspan="4"></td>
</tr>
</table>
</td>
</tr>
</table>
</html:form>

【struts-config.xml】
<struts-config>
<data-sources />
<form-beans>
<form-bean name="userForm" type="com.ibatis.struts.form.UserForm" />
</form-beans>
<global-exceptions />
<global-forwards />

<action-mappings>
<action path="/userAction" scope="request" 
type="com.ibatis.struts.action.UserAction" name="userForm" input="/index.jsp">
<forward name="success" path="/success.jsp"></forward>
<forward name="fail" path="/fail.jsp"></forward>
</action>
</action-mappings>
</struts-config>

【UserAction】
public class UserAction extends Action{

private UserForm userForm;

private UserDao userDao;

/**
* @param userDao the userDao to set
*/
public void setUserDao(UserDao userDao) {
this.userDao = userDao;
}

public ActionForward logic(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)throws Exception {

// 取得画面上的数据
userForm = (UserForm) form;

// 去数据库验证用户名密码
User userParam = new User();

userParam.setName(userForm.getName());
userParam.setPasswd(userForm.getPasswd());
User user = (User) userDao.getUser(userParam);

// 对检索结果进行验证
if (user.getName() == null || "".equals(user.getName())){
return mapping.findForward("fail");
} else {
return mapping.findForward("success&quo