异常 parameters.grid [在模板 "template/jquery/gridcolumn.ftl"
Exception parameters.grid [in template "template/jquery/gridcolumn.ftl"
我正在尝试使用 Struts 2 jquery 网格插件以及 struts jquery 插件和 struts json 插入。我是初学者。
这是我的 JSP 代码:
<s:form action="misinfo">
<s:textfield name="sdate" label="START DATE"></s:textfield>
<s:textfield name="edate" label="END DATE"></s:textfield>
<s:submit value="submit"></s:submit>
</s:form>
<s:url var="remoteurl" action="jsontable" />
<sjg:grid id="gridTable" caption="login ID" dataType="json"
href="%{remoteurl}" pager="true" gridModel="gridModel"
rowList="10,15,20" rowNum="15" rownumbers="true" />
<sjg:gridColumn name="login ID"/>
<sjg:gridColumn name="select" />
struts.xml
<package name="mypackage" namespace="/" extends="struts-default, json-default">
<result-types>
<result-type name="json" class="org.apache.struts2.json.JSONResult" default="true"/>
<result-type name="dispatcher" class="org.apache.struts2.dispatcher.ServletDispatcherResult" default="true"/>
</result-types>
<action name="mis" class="com.action.JsonAction">
<result name="success">/WEB-INF/jsp/mis.jsp</result>
<result name="input">/WEB-INF/jsp/mis.jsp</result>
</action>
<action name="jsontable" class="com.action.JsonAction">
<result name="success">/WEB-INF/jsp/mis.jsp</result>
</action>
</package>
操作class
public class JsonAction extends ActionSupport {
private String gridModel;
private int rows = 0;
private int page = 0;
private String sortAsc;
private String sortIndex;
private String searchField;
private String searchOprtn;
private int total = 0;
private int records = 0;
@Override
public String execute() throws Exception {
int to = (rows * page);
int from = to - rows;
JsonActionDao jsn = new JsonActionDaoImpl();
records = jsn.getNoOfRecords();
gridModel = jsn.getRecords();
total = (int) Math.ceil((double) records / (double) rows);
System.out.println("row "+rows+"page "+page+"gridModel "+gridModel);
return "success";
// getter and setter for fields.,,,....
}
}
我得到异常
The following has evaluated to null or missing:
==> parameters.grid [in template "template/jquery/gridcolumn.ftl" at line 22, column 29]
----
Tip: It's the step after the last dot that caused this error, not those before it.
----
Tip: If the failing expression is known to be legally refer to something that's null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing</#if>. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)??
----
----
FTL stack trace ("~" means nesting-related):
- Failed at: ${parameters.grid?string?replace(".",... [in template "template/jquery/gridcolumn.ftl" at line 22, column 27]
- Reached through: #assign escapedOptionId = "${paramet... [in template "template/jquery/gridcolumn.ftl" at line 22, column 1]
----
Java stack trace (for programmers):
----
freemarker.core.InvalidReferenceException: [... Exception message was already printed; see it above ...]
grid
标签不应该是自闭的,它应该有一个放置 gridCoumn
标签的正文。
列的 name
应该是 gridModel
的 属性,作为 bean 的 属性 必须是标识符,即没有空格。
网格模型应该是通过调用您在 href
属性中使用的操作重新序列化为 JSON 的对象列表。
<sjg:grid id="gridTable" caption="login ID" dataType="json"
href="%{remoteurl}" pager="true" gridModel="gridModel"
rowList="10,15,20" rowNum="15" rownumbers="true">
<sjg:gridColumn name="loginID"/>
<sjg:gridColumn name="select" />
</sjg:grid>
您可以使用 Grid Tag 的项目维基页面找到网格示例。
我正在尝试使用 Struts 2 jquery 网格插件以及 struts jquery 插件和 struts json 插入。我是初学者。
这是我的 JSP 代码:
<s:form action="misinfo">
<s:textfield name="sdate" label="START DATE"></s:textfield>
<s:textfield name="edate" label="END DATE"></s:textfield>
<s:submit value="submit"></s:submit>
</s:form>
<s:url var="remoteurl" action="jsontable" />
<sjg:grid id="gridTable" caption="login ID" dataType="json"
href="%{remoteurl}" pager="true" gridModel="gridModel"
rowList="10,15,20" rowNum="15" rownumbers="true" />
<sjg:gridColumn name="login ID"/>
<sjg:gridColumn name="select" />
struts.xml
<package name="mypackage" namespace="/" extends="struts-default, json-default">
<result-types>
<result-type name="json" class="org.apache.struts2.json.JSONResult" default="true"/>
<result-type name="dispatcher" class="org.apache.struts2.dispatcher.ServletDispatcherResult" default="true"/>
</result-types>
<action name="mis" class="com.action.JsonAction">
<result name="success">/WEB-INF/jsp/mis.jsp</result>
<result name="input">/WEB-INF/jsp/mis.jsp</result>
</action>
<action name="jsontable" class="com.action.JsonAction">
<result name="success">/WEB-INF/jsp/mis.jsp</result>
</action>
</package>
操作class
public class JsonAction extends ActionSupport {
private String gridModel;
private int rows = 0;
private int page = 0;
private String sortAsc;
private String sortIndex;
private String searchField;
private String searchOprtn;
private int total = 0;
private int records = 0;
@Override
public String execute() throws Exception {
int to = (rows * page);
int from = to - rows;
JsonActionDao jsn = new JsonActionDaoImpl();
records = jsn.getNoOfRecords();
gridModel = jsn.getRecords();
total = (int) Math.ceil((double) records / (double) rows);
System.out.println("row "+rows+"page "+page+"gridModel "+gridModel);
return "success";
// getter and setter for fields.,,,....
}
}
我得到异常
The following has evaluated to null or missing:
==> parameters.grid [in template "template/jquery/gridcolumn.ftl" at line 22, column 29]
----
Tip: It's the step after the last dot that caused this error, not those before it.
----
Tip: If the failing expression is known to be legally refer to something that's null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing</#if>. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)??
----
----
FTL stack trace ("~" means nesting-related):
- Failed at: ${parameters.grid?string?replace(".",... [in template "template/jquery/gridcolumn.ftl" at line 22, column 27]
- Reached through: #assign escapedOptionId = "${paramet... [in template "template/jquery/gridcolumn.ftl" at line 22, column 1]
----
Java stack trace (for programmers):
----
freemarker.core.InvalidReferenceException: [... Exception message was already printed; see it above ...]
grid
标签不应该是自闭的,它应该有一个放置 gridCoumn
标签的正文。
列的 name
应该是 gridModel
的 属性,作为 bean 的 属性 必须是标识符,即没有空格。
网格模型应该是通过调用您在 href
属性中使用的操作重新序列化为 JSON 的对象列表。
<sjg:grid id="gridTable" caption="login ID" dataType="json"
href="%{remoteurl}" pager="true" gridModel="gridModel"
rowList="10,15,20" rowNum="15" rownumbers="true">
<sjg:gridColumn name="loginID"/>
<sjg:gridColumn name="select" />
</sjg:grid>
您可以使用 Grid Tag 的项目维基页面找到网格示例。