我想在对Struts2 jQuery网格的值进行一些服务器端验证后,在网格顶部显示操作错误。任何帮助都将不胜感激。
这是我的操作错误。
addActionError("You can not delete this data");但不幸的是,我无法在jsp页面中显示错误。请分享你对这个问题的认识。
发布于 2013-03-06 19:41:12
尝尝这个
基本概念:您必须创建一个jsp。
假设返回error.jsp并返回错误,只需加载error.jsp即可。
在error.jsp中写入addActionError("You can not delete this data");。
并将此error.jsp包含到您希望显示错误消息的主网格页面中
发布于 2013-03-27 18:02:57
对于服务器端验证,我在提交后事件时使用json响应,如下所示
navGrid("#pager2",{}, //options
{height:280,width:700,reloadAfterSubmit:false}, // edit options
{height:280,width:700,reloadAfterSubmit:false,
afterSubmit : function(response, postdata) {
var msg = "noError";
var res = $.parseJSON(response.responseText);
if (res && res.userMessage) {
alert(res.userMessage);
msg = res.userMessage;
}
//alert(msg);
if(msg == "noError") {
return [true, "Validation pass"];
} else {
return [false, msg];
}
}}, // add options
{reloadAfterSubmit:false}, // del options
{} // search options
);和struts条目
<action name="jsontableEditValidationApartmentResource" class="com.loa.monitor.action.JsonActionResource" method="editValidate" >
<result name="success" type = "json"></result>
<result name="error" type="redirectAction">
<param name="actionName">proceedApartment</param>
</result>
</action>和动作方法
public String editValidate() {
userMessage = "test msg1";
return "success";
}
private String userMessage ;
public String getUserMessage() {
return userMessage;
}
public void setUserMessage(String userMessage) {
this.userMessage = userMessage;
}让我知道这是否有用
https://stackoverflow.com/questions/15244571
复制相似问题