struts2 从 2.3.16 更新到 2.3.32(修复 S2-045)后,JSP 文件无法解析某些对象的字段
After having updated struts2 from 2.3.16 to 2.3.32(fix the S2-045), the JSP file can not resolve some Objects' fields
最近我们修复了 struts2 的 'S2-045' problem.I 更新了所有 struts2
相关的 jar 文件,包括 freemarker
、ognl
、xWork
等。我使用 tomcat8
来部署我的动态 Web 项目。启动 tomcat-服务器时没有任何 Exceptions
。但是似乎出现了一些问题:一些值(从数据库中获取)应该显示在jsp页面上不再显示 .没有 Exceptions
抛出。我还可以看到我已经在 Action Classes
中正确地得到了非常对象。
以下是一些例子
// index.jsp ----- here is the list I want to show on the page.
// the list is the type of List<News> (Class News is my bussiness Class).
// I want to get the 'fTitle' and 'fCreatetime_s' from 'News' but they
// do not show up! (This used to be working very well.)
<s:bean name="org.ulibrary.web.Getarclist">
<s:iterator value="list">
<li>
<span class="listTitle">
<a target="_blank" href="ViewArc.action? uuid=${UUID}">${fTitle}</a>
</span>
<span class="listDate">${fCreatetime_s}</span>
</li>
</s:iterator>
</s:bean>
//=================================================================
以下是相关字段 id News.java
// News.java (**just some ralated fields**)
class News{
@Id
@GeneratedValue(generator = "system-uuid")
@GenericGenerator(name = "system-uuid", strategy = "uuid")
@Column(name = "f_uuid", length = 32, unique = true)
private String UUID;
@Column(name = "f_title", length = 200)
private String fTitle;
@Transient
private String fCreatetime_s;
public String getUUID() {
return UUID;
}
public void setUUID(String uuid) {
UUID = uuid;
}
public String getFTitle() {
return fTitle;
}
public void setFTitle(String title) {
fTitle = title;
}
public String getFCreatetime_s() {
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
return formatter.format(Long.valueOf(fCreatetime));
}
public void setFCreatetime_s(String createtime_s) {
fCreatetime_s = createtime_s;
}
}
然后是 GetarcList.java
//GetarcList.java (just include some related fields)
class GetarcList{
private List list;
public void setList(List list) {
this.list = list;
}
//!!!!!!$$$$$$$$--- Attention -----$$$$$$$$$!!!!!!!!!!!
// this method returns a List<News> , I can successfully get every value of 'News' in the list
public List getList() throws AuctionException{
String orderby_str = (String) OrderByMap.get(String.valueOf(orderby));
list = webTagManager.getArcList(row, typeid, titlelen, infolen, orderby_str + " " + orderway);
return list;
}
}
我认为这可能是由 OGNL 或 JSP 相关的 jar 文件引起的。我在 index.jsp
或 java 文件中没有发现任何问题。
您需要按以下格式使用getters/setters。只有一个开头小写字母的属性不会大写。
public String getfTitle() {
return fTitle;
}
public void setfTitle(String title) {
fTitle = title;
}
最近我们修复了 struts2 的 'S2-045' problem.I 更新了所有 struts2
相关的 jar 文件,包括 freemarker
、ognl
、xWork
等。我使用 tomcat8
来部署我的动态 Web 项目。启动 tomcat-服务器时没有任何 Exceptions
。但是似乎出现了一些问题:一些值(从数据库中获取)应该显示在jsp页面上不再显示 .没有 Exceptions
抛出。我还可以看到我已经在 Action Classes
中正确地得到了非常对象。
以下是一些例子
// index.jsp ----- here is the list I want to show on the page.
// the list is the type of List<News> (Class News is my bussiness Class).
// I want to get the 'fTitle' and 'fCreatetime_s' from 'News' but they
// do not show up! (This used to be working very well.)
<s:bean name="org.ulibrary.web.Getarclist">
<s:iterator value="list">
<li>
<span class="listTitle">
<a target="_blank" href="ViewArc.action? uuid=${UUID}">${fTitle}</a>
</span>
<span class="listDate">${fCreatetime_s}</span>
</li>
</s:iterator>
</s:bean>
//=================================================================
以下是相关字段 id News.java
// News.java (**just some ralated fields**)
class News{
@Id
@GeneratedValue(generator = "system-uuid")
@GenericGenerator(name = "system-uuid", strategy = "uuid")
@Column(name = "f_uuid", length = 32, unique = true)
private String UUID;
@Column(name = "f_title", length = 200)
private String fTitle;
@Transient
private String fCreatetime_s;
public String getUUID() {
return UUID;
}
public void setUUID(String uuid) {
UUID = uuid;
}
public String getFTitle() {
return fTitle;
}
public void setFTitle(String title) {
fTitle = title;
}
public String getFCreatetime_s() {
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
return formatter.format(Long.valueOf(fCreatetime));
}
public void setFCreatetime_s(String createtime_s) {
fCreatetime_s = createtime_s;
}
}
然后是 GetarcList.java
//GetarcList.java (just include some related fields)
class GetarcList{
private List list;
public void setList(List list) {
this.list = list;
}
//!!!!!!$$$$$$$$--- Attention -----$$$$$$$$$!!!!!!!!!!!
// this method returns a List<News> , I can successfully get every value of 'News' in the list
public List getList() throws AuctionException{
String orderby_str = (String) OrderByMap.get(String.valueOf(orderby));
list = webTagManager.getArcList(row, typeid, titlelen, infolen, orderby_str + " " + orderway);
return list;
}
}
我认为这可能是由 OGNL 或 JSP 相关的 jar 文件引起的。我在 index.jsp
或 java 文件中没有发现任何问题。
您需要按以下格式使用getters/setters。只有一个开头小写字母的属性不会大写。
public String getfTitle() {
return fTitle;
}
public void setfTitle(String title) {
fTitle = title;
}