Struts2 struts 2 jqgrid自定义导航编辑

Struts2 struts 2 jqgrid自定义导航编辑,struts2,jqgrid,struts2-jquery-grid,Struts2,Jqgrid,Struts2 Jquery Grid,我的项目需要定制jqgrid编辑和删除选项,即具有编辑和删除前置项的用户可以编辑和删除网格数据 我找到了一个用于此目的的代码 String edit_permission=util.getEdit_permission; String delete_permission=util.getDelete_permission; //将字符串设置为true或false,工作正常 ValueStack stack=ActionContext.getContext.getValueStack; stack

我的项目需要定制jqgrid编辑和删除选项,即具有编辑和删除前置项的用户可以编辑和删除网格数据

我找到了一个用于此目的的代码

String edit_permission=util.getEdit_permission; String delete_permission=util.getDelete_permission; //将字符串设置为true或false,工作正常 ValueStack stack=ActionContext.getContext.getValueStack; stack.getContext.puttedit_权限,edit_权限; stack.setValueattr['edit_permission'],edit_permission,false; jqgrid代码片段

这段代码在我使用的地方运行良好,但在我的情况下,它抛出了一个错误。这是日志

WARNING: Error setting expression '#attr['edit_permission']' with value 'true'
ognl.OgnlException: target is null for setProperty(null, "edit_permission", true)
at ognl.OgnlRuntime.setProperty(OgnlRuntime.java:2219)
at ognl.ASTProperty.setValueBody(ASTProperty.java:127)
at ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:220)
at ognl.SimpleNode.setValue(SimpleNode.java:301)
at ognl.ASTChain.setValueBody(ASTChain.java:227)
at ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:220)
at ognl.SimpleNode.setValue(SimpleNode.java:301)
at ognl.Ognl.setValue(Ognl.java:737)......


WARNING: Error setting expression '#attr['delete_permission']' with value 'true'
ognl.OgnlException: target is null for setProperty(null, "delete_permission", true)
at ognl.OgnlRuntime.setProperty(OgnlRuntime.java:2219)
at ognl.ASTProperty.setValueBody(ASTProperty.java:127)
at ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:220)
at ognl.SimpleNode.setValue(SimpleNode.java:301)
at ognl.ASTChain.setValueBody(ASTChain.java:227)
at ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:220)
at ognl.SimpleNode.setValue(SimpleNode.java:301)
at ognl.Ognl.setValue(Ognl.java:737)
at com.opensymphony.xwork2.ognl.OgnlUtil.setValue(OgnlUtil.java:198)
at com.opensymphony.xwork2.ognl.OgnlValueStack.setValue(OgnlValueStack.java:161)
at org.apache.jsp.Production.projectIdCreation_jsp._jspService(projectIdCreation_jsp.java:306)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
我无法找出此错误的实际原因…请提供帮助。

操作:

private String editPermission;
private String deletePermission; 

public String execute() throws Exception{
    editPermission = util.getEdit_permission();
    deletePermission = util.getDelete_permission();
    return SUCCESS;
}

/* Getters */

public String getEditPermission(){
    return editPermission;
}

public String getDeletePermission(){
    return deletePermission;
}
使用Eclipse AltShift生成getter,然后生成getter和setter

然后,在JSP中,在网格代码内部:

...
  navigatorEdit = "%{editPermission}"
navigatorDelete = "%{deletePermission}"
...

你做得很扭曲。为什么不在getter中使用两个简单变量??:|ALT+SHIFT+S和R:I know dude}:D我将其扩展以明确正确链接的位置和位置: