我是ssh整合的....action是用spring注入的,表单验证失败的时候没有跳转回去...而且还提交了数据在console里颗粒看到信息
ERROR net.action.AdminAction - Validation error for admin.name:管理员姓名不可为空
Hibernate: insert into net.admins (name, loginname, loginpassword, phone, email, enrolldate) values (?, ?, ?, ?, ?, ?)struts-xml里的input也写了...不知道是不是因为action是spring注入的问题?请高手指点下啊..后天就要审核了....
ERROR net.action.AdminAction - Validation error for admin.name:管理员姓名不可为空
Hibernate: insert into net.admins (name, loginname, loginpassword, phone, email, enrolldate) values (?, ?, ?, ?, ?, ?)struts-xml里的input也写了...不知道是不是因为action是spring注入的问题?请高手指点下啊..后天就要审核了....
就是服务器端的验证算然判断出是错误表单了但是他没有跳转回去....继续执行action了.....囧啊~~~~
package net.action;import java.util.List;import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;import net.domain.admin.Admin;
import net.domain.admin.AdminView;
import net.domain.right.Role;
import net.service.admin.AdminService;import org.apache.log4j.Logger;
import org.apache.struts2.ServletActionContext;public class AdminAction { private Admin admin; private Admin loginAdmin; private List<Admin> admins; private List<Role> roles; private AdminView av; private AdminService as; private Integer id; private Logger logger = Logger.getLogger(AdminAction.class); public Admin getLoginAdmin() {
return loginAdmin;
} public void setLoginAdmin(Admin loginAdmin) {
this.loginAdmin = loginAdmin;
} public AdminView getAv() {
return av;
} public void setAv(AdminView av) {
this.av = av;
} public List<Role> getRoles() throws Exception {
return this.roles;
} public Integer getId() {
return id;
} public void setId(Integer id) {
this.id = id;
} public Admin getAdmin() {
return admin;
} public void setAdmin(Admin admin) {
this.admin = admin;
} public List<Admin> getAdmins() {
return admins;
} public void setAs(AdminService as) {
this.as = as;
} public String adminList() throws Exception {
admins = as.getAdminList();
return "ok";
} public String modifyAdminInfoPage() throws Exception {
HttpServletRequest request = ServletActionContext.getRequest();
HttpSession session = request.getSession();
loginAdmin = (Admin) session.getAttribute("loginAdmin");
return "ok";
} public String modifyAdminInfo() throws Exception {
as.modifyAdminInfo(loginAdmin);
return "ok";
} public String addAdmin() throws Exception {
as.addAdmin(admin);
admins = as.getAdminList();
return "ok";
} public String addAdminPage() throws Exception {
roles = as.getRoleList();
return "ok";
} public String deleteAdmin() throws Exception {
as.deleteAdmin(id);
admins = as.getAdminList();
return "ok";
} public String deleteAdminList() throws Exception {
admins = as.getAdminList();
return "ok";
} public String modifyAdmin() throws Exception {
as.modifyAdmin(admin);
admins = as.getAdminList();
return "ok";
} public String modifyAdminPage() throws Exception {
admin = as.getAdminById(id);
roles = as.getRoleList();
return "ok";
} public String modifyAdminList() throws Exception {
admins = as.getAdminList();
return "ok";
} public String adminListSerch() throws Exception {
logger.debug("action " + av.getEnRollDateBegin());
admins = as.getAdminListByAdminView(av);
return "ok";
} public String deleteAdminListSerch() throws Exception {
admins = as.getAdminListByAdminView(av);
return "ok";
} public String modifyAdminListSerch() throws Exception {
admins = as.getAdminListByAdminView(av);
return "ok";
}
}这是action的代码....struts2不是不用处理的么....<validators> <field name="admin.name">
<field-validator type="requiredstring">
<message>${getText("admin.name.null")}</message>
</field-validator>
</validators>
这是validation的....<action name="addAdmin" class="AdminAction" method="addAdmin">
<result name="input">
/WEB-INF/jsp/admin/adminadd.jsp
</result>
<result name="ok">/WEB-INF/jsp/admin/adminlist.jsp
</result>
</action>
这个是struts-xml的...页面上用的是标记库
<s:fielderror cssStyle="color: red"></s:fielderror>提交了以后终端上显示了
ERROR net.action.AdminAction - Validation error for admin.name:管理员姓名不可为空但是仍然提交了数据..
请各位指点下