actiong:
UserAction文件
public String login() throws Exception {
System.out.println(user.getUserName());
System.out.println(user.getPassWord());
System.out.println("service-->"+service);
if (service.isLogin(user)) {
System.out.println("执行登陆impl成功");
Map session = ActionContext.getContext().getSession();
session.put("username", user.getUserName());
return "success";
}
return "input";
}
新建一个UserAction-validation.xml文件
<validators>
<field name="userName">
<field-validator type="requiredstring">
<param name="trim">true</param>
<message>name is required</message>
</field-validator>
</field>
</validators>
jsp页面
<s:fielderror>
<s:param>userName</s:param>
</s:fielderror>