2015-11-05 65 views
0


这里是我的问题:
我使用的Liferay 6.2,与Struts2的

我想用DisplayTag为分页,但没有按表没有出现,并且Liferay向我显示此消息“没有任何发现显示。”
Liferay6.2:DisplayTag在Struts2 - “没有显示”

我需要显示3名学生在一个HTML表:

我把所有的代码(波纹管)的一个简单而经典的“动态Web项目”与Tomcat7,我可以看到我的3名学生。
但在这里,与Liferay的,我已经得到了消息 “没有显示。”

web.xml中:

<web-app [...]> 
    <display-name>HelloStruts</display-name> 
    <display-name>Struts 2 Web Application</display-name> 
    <filter> 
     <filter-name>struts2</filter-name> 
     <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class> 
    </filter> 
    <filter-mapping> 
     <filter-name>struts2</filter-name> 
     <url-pattern>/*</url-pattern> 
    </filter-mapping> 
</web-app> 



struts.xml中:

<struts> 
    <constant name="struts.devMode" value="true" /> 
    <package namespace="/view" extends="struts-portlet-default" name="view"> 
     <action name="viewDisplayTags" class="com.displaytags.StudentAction" method="fetchStudentList"> 
      <result name="success">/html/displaytags/viewDisplayTags.jsp</result> 
     </action> 
    </package> 
</struts> 



StudentAction.java:

public class StudentAction extends ActionSupport { 
    private List<StudentBean> students = new ArrayList<StudentBean>(); 

    public String fetchStudentList() { 
     students.add(new StudentBean("o7bb002", "Ajay")); 
     students.add(new StudentBean("o7bc055", "Mohiadeen")); 
     students.add(new StudentBean("o7bc074", "Sriram Ganesh")); 

     return SUCCESS; 
    } 

    public List<StudentBean> getStudents() { 
     return students; 
    } 

    public void setStudents(List<StudentBean> students)  { 
     this.students = students; 
    } 
} 

StudentBean.java

public class StudentBean { 

    private String rollNo; 
    private String studentName; 

    public StudentBean(String rollNo, String studentName) { 
     this.rollNo = rollNo; 
     this.studentName = studentName; 
    } 

    public String getRollNo() { 
     return rollNo; 
    } 

    public void setRollNo(String rollNo) { 
     this.rollNo = rollNo; 
    } 

    public String getStudentName() { 
     return studentName; 
    } 

    public void setStudentName(String studentName) { 
     this.studentName = studentName; 
    } 
} 

viewDisplayTags.jsp

<%@taglib prefix="s" uri="/struts-tags" %> 
<%@ include file="/html/init.jsp" %> 
<%@ include file="headerDisplayTags.jspf" %> 

<%@ taglib prefix="display" uri="http://displaytag.sf.net"%> 

<s:hidden name="studentsHiddenList" value="%{students}" /> 

<display:table name="students"> 
    <display:column property="rollNo" title="Roll No" sortable="true"></display:column> 
    <display:column property="studentName" title="Student Name" sortable="true" ></display:column> 
</display:table> 


这是奇怪的,因为与“隐藏”(在“viewDisplayTags.jsp”),我可以看到我的3名学生的内容......学生列表是从Java类传递到JSP


谢谢!

回答

0

我终于找到了答案:
清单“学生”没有在“请求”,并在“属性requestURI”设置不正确


StudentAction.java:

public class StudentAction extends ActionSupport { 
    private List<StudentBean> students = new ArrayList<StudentBean>(); 

    public String fetchStudentList() { 
     students.add(new StudentBean("o7bb002", "Ajay")); 
     students.add(new StudentBean("o7bc055", "Mohiadeen")); 
     students.add(new StudentBean("o7bc074", "Sriram Ganesh")); 

     Map request = (Map) ActionContext.getContext().get("request"); 
     request.put("students",students); 

     return SUCCESS; 
    } 

    public List<StudentBean> getStudents() { 
     return students; 
    } 

    public void setStudents(List<StudentBean> students) { 
     this.students = students; 
    } 
} 

viewDisplayTags.jsp

<%@taglib prefix="s" uri="/struts-tags" %> 
<%@ include file="/html/init.jsp" %> 
<%@ include file="headerDisplayTags.jspf" %> 

<%@ taglib prefix="display" uri="http://displaytag.sf.net"%> 

<s:hidden name="studentsHiddenList" value="%{students}" /> 

<display:table name="students" class="StudentAction" requestURI="/viewDisplayTags.jsp"> 
    <display:column property="rollNo" title="Roll No" sortable="true"></display:column> 
    <display:column property="studentName" title="Student Name" sortable="true" ></display:column> 
</display:table> 
+0

MMNO,这并不是说,这是一种解决方法...只是用户requestURI和id的页面和#attr。从displaytag访问请求数据:http://www.simplecodestuffs.com/struts-2-tag-not-working-inside-a-display-tag-solution/ –