register.jsp
<%@page contentType="text/html;charset=gb2312" %>
<%@taglib prefix="s" uri="/struts-tags"%>
<html>
<body>
<form action="register.action" method="post" name="register">
用户名:<input type="text" name="user.username"/><br>
密 码:<input type="password" name="user.password"/><br>
性别:<input type="text" name="user.sex"/><br>
年龄:<input type="text" name="user.age"/><br>
<input type="submit" value="注册"><br>
</form>
</body>
</html>
struts.xml
<action name="register" class="action.UserAction" method="register">
<result name="success">/register_success.jsp</result>
</action>
action
public String register() throws Exception{
System.out.print("sdfsdfsdfsdfsdfsdfs1111111");
userService.saveUser(user);
return SUCCESS;
}
有时行,有时不行,谁能告诉我什么原因啊!!
type Status report
message No result defined for action action.UserAction and result input
description The requested resource (No result defined for action action.UserAction and result input) is not available.
最好告诉我怎么排查错误,先多谢各位大侠啦
action input
------解决方案--------------------
message No result defined for action action.UserAction and result input
没有result name=input的结果映射
如果页面正常输入,后台处理成功,那么走success界面;如果后台校验失败,会把error存放在指定变量中,这时默认result的name为input,而你没有配置,所以报错。