Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.2k views
in Technique[技术] by (71.8m points)

java - 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

Recently we fixed the struts2's 'S2-045' problem.I updated all the struts2 related jar files including freemarker, ognl, xWork,etc. I use tomcat8 to deploy my dynamic web project. There were not any Exceptions while starting the tomcat-server. But some problems seemed occur: some values(got from db) should be displayed on the jsp pages dose not show up any more. There is no Exceptions thrown. I also can watch that I have already got the very Objects correctly in the Action Classes.


the following is some examples
    // 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>
    //=================================================================

Following is the ralated fields 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;
        }
    }  

and then the 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;
         }

    }

I think this maybe caused by the OGNL or JSP related jar-files. I didn't find any problems in my index.jsp or java-files.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You need to use getters/setters in the following format. Properties with only one starting lowercase letter are not uppercased.

    public String getfTitle() {
        return fTitle;
    }


    public void setfTitle(String title) {
        fTitle = title;
    }

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...