1.index.jsp
<a
href="user/user!add?name=a">添加用户</a>
2。use_add_error.jsp
<s:property
value="errors.name[0]"/>
<s:debug></s:debug>
3.Struts.xml
<package
name="user" extends="struts-default"
namespace="/user">
4.UseAction 验证
package cn.vcy168.user.action;
import com.opensymphony.xwork2.ActionSupport;
public class
UserAction extends ActionSupport {
private String name;
public
String add()
{
//addFieldError
记录map格式的内容 key=name value=name is
error
}
public
String getName() {
}
public void
setName(String name) {
}
}
因为index.jsp中name=a
本文深入探讨了Struts框架中index.jsp页面通过DMI动态方法调用UserAction类的add()方法实现用户添加功能的过程,以及使用Struts.xml配置文件进行路由管理。详细解释了如何在UserAction类中验证参数并根据不同返回结果跳转至不同的JSP页面展示成功或错误信息。
1万+

被折叠的 条评论
为什么被折叠?



