1

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.

Roman C
  • 49,761
  • 33
  • 66
  • 176
Chason Luis
  • 23
  • 1
  • 4

1 Answers1

1

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;
    }
Roman C
  • 49,761
  • 33
  • 66
  • 176
  • thanks a lot , it realy works. I did not notice that before. – Chason Luis Mar 14 '17 at 08:32
  • Will this incorrect getter and setter name work in previous version( 2.3.16) also? Or is this part of 2.3.32 version alone, explicitly. @Roman I know that we had a discussion around Boolean setter before, http://stackoverflow.com/q/36909947/5086633 – yeppe Mar 20 '17 at 10:21
  • 1
    @yeppe It's affected only version 2.3.32 and probably above. To be more precise OGNL version 3.0.11 (OgnlRuntime) which is bundled with Struts2 framework. – Roman C Mar 20 '17 at 10:29