我已經閱讀了所有的例子,展示了使用struts2展示jqgrid。但是我的網格沒有顯示出來。請幫助我。以下是我的代碼片段。當我在url中輸入動作名稱時,它會顯示我的json。當我在url中鍵入jsp路徑時,它不會顯示我的jqgrid。但是當我查看頁面的源代碼時,它會爲jqgrid創建代碼。struts 2 jqGrid沒有顯示
JSP文件
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@taglib prefix="sj" uri="/struts-jquery-tags" %>
<%@taglib prefix="sjg" uri="/struts-jquery-grid-tags" %>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<sj:head jqueryui="true" jquerytheme="redmond"></sj:head>
</head>
<body>
<s:url id="remoteurl" action="/SreebhogStore/incomingRawMaterial1" />
<sjg:grid id="gridtable" caption="Roles" dataType="json" href="%{remoteurl}" pager="true" gridModel="gridModel" rowList="10,15,20" rowNum="5" rownumbers="true"
width="800" navigator="true" navigatorView="false" navigatorDelete="false"
navigatorAdd="false" navigatorEdit="false" navigatorSearch="false">
<sjg:gridColumn name="lotNo" index="lotNo" title="Role Name"
sortable="true" formatter="editrole" />
</sjg:grid>
</body>
</html>
Struts 2的配置
<package name="incomingRawMaterialManagement" extends="struts-default, json-default" namespace="/SreebhogStore">
<interceptors>
<interceptor name="login" class="com.sreebhog.interceptors.LoginInterceptor" />
<interceptor-stack name="loginStack">
<interceptor-ref name="login" ></interceptor-ref>
<interceptor-ref name="defaultStack" ></interceptor-ref>
</interceptor-stack>
</interceptors>
<default-interceptor-ref name="loginStack"></default-interceptor-ref>
<action name="incomingRawMaterial1" class="com.sreebhog.actions.IncomingRawMaterialAction">
<result name="success" type="json"></result>
</action>
</package>
這裏是我的動作類
public class IncomingRawMaterialAction extends ActionSupport implements LoginRequired,SessionAware,ErrorSuccessMessages
,ServletRequestAware{
private static final long serialVersionUID = 1L;
private Map<String, Object> sessionMap;
HttpServletRequest request;
//For incoming raw material initialization
private List<Products> rawMaterials;
private List<Party> parties;
//For jqGrid
private List<IncomingRawMaterial> gridModel;
private Integer rows = 0; //Number of rows
private Integer page = 0; //Get the requested page. By default grid sets this to 1.
private String sort; // sorting order - asc or desc
private String sidx; // get index row - i.e. user click to sort.
private String searchString; // The Search String
private String searchOper; // The Search Operation ['eq','ne','lt','le','gt','ge','bw','bn','in','ni','ew','en','cn','nc']
private Integer total = 0; // Your Total Pages
private Integer records = 0; // All Record
public String execute()
{
rows=5;
gridModel = new ArrayList<IncomingRawMaterial>();
gridModel.add(new IncomingRawMaterial());
gridModel.add(new IncomingRawMaterial());
System.out.println("HERE--------------------------------------------------");
//calculate the total pages for the query
total =2;//(int) Math.ceil((double)records/(double)rows);
return SUCCESS;
}
public String getJSON()
{
System.out.println("JSON------------------------------------------------------");
return execute();
}
//Getters and setters and override methods
//JQGRID GETTERS AND SETTTERS
}
請注意,也沒有得到顯示控制檯消息。所以我懷疑jqgrid不會調用我的動作。
這裏是罐子的名單中包括 ANTLR-2.7.7.jar 同學-0.5.4.jar 公地集合-3.2.1.jar 公地文件上傳-1.2.1.jar commons- IO-1.3.2.jar 共享記錄-1.0.4.jar 的dom4j-1.6.1.jar freemarker的-2.3.15.jar 休眠公地的註解 - 4.0.1.Final.jar hibernate- core-4.0.0.Final.jar hibernate-jpa-2.0-api-1.0.1.Final.jar javassist-3.12.1.GA.jar jandex-1.0.3.Final.jar jboss-logging- 3.1.0.CR2.jar jboss-transaction-api_1.1_spec-1.0.0.Final.jar log4j-1.2.14.jar mysql-connector-java-5.1.3-rc-bin.jar ognl-2.7.3.jar servlet -api.jar Struts2的會展 - 插件 - 2.1.8.1.jar XWork的核心 - 2.1.6.jar
**Here are the important ones i guess.**
struts2-core-2.1.8.1.jar
struts2-jquery-grid-plugin-3.5.1.jar
struts2-jquery-plugin-3.5.1.jar
struts2-json-plugin-2.1.8.1.jar
編輯1: 我能夠立即查看我的網格,但它仍然是不加載json數據。問題在於sjg:column標籤之一中的formatter屬性。
可能的重複http://stackoverflow.com/questions/15590992/struts-2-jqgrid-not-getting-displayed – 2013-03-24 14:51:04
是的。是我問這個問題的。但由於我沒有收到任何答覆,我想再次提出這個問題。 Anywayz,該問題已被刪除。 – 2013-03-24 16:24:49
因爲沒有得到關注,您不想重複發佈相同的問題兩次。隨着更多的聲譽,你可以附加賞金來獲得更多的外觀。另外,如果您已經回答了問題,請隨時在下面回答您的問題並接受它。 – Makoto 2013-03-24 18:02:13