簡體   English   中英

速度用戶提供的帶有Struts 1.2的JSP

[英]JSP with Struts 1.2 from a velocity user

我們有運行Struts 1.2和Velocity的成熟應用程序,我需要將頁面從vm轉換為jsp。

因此,我修改了struts-config,將前向更改為一個新的JSP文件,並在JSP中嘗試顯示一些分配給表單bean的數據,但所有表單屬性在JSP中均顯示為空。 當我查看表單本身時,我看到它們是不同的對象。 因此,以某種方式,我在Action中使用的Form Bean與JSP所看到的不一樣。

有任何想法嗎?

        <form-beans>  

        <form-bean name="scheduleDisplayForm" type="web.scheduler.ScheduleDisplayForm"/>  

    </form-beans>  

    <action-mappings>  
        <action path="/displaySchedule"  
                type="web.scheduler.ScheduleDisplayAction"  
               name="scheduleDisplayForm" scope="request" parameter="method">  

           <!--<forward name="success" path="/scheduler/scheduler.vm"/>-->  
           <forward name="success" path="/scheduler/scheduler.jsp"/>  
       </action>  
   </action-mappings>  

在我的JSP中,我只是嘗試這樣做:

       <%@ page contentType="text/html" %>  
   <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>  
   <%@ taglib prefix="h" uri="http://java.sun.com/jsp/jstl/xml" %>  
   <%@ taglib prefix="b" uri="http://jakarta.apache.org/struts/tags-bean" %>  

   <jsp:useBean id="schedule" class="web.scheduler.ScheduleDisplayForm" scope="request"/>  

   <!-- display the object -->  
   <%=schedule%>
   <!-- shows NULL -->  
   <%=schedule.getRoomsToDisplay()%>

感謝Vincent和dpb!

我明白了 在Struts配置中,我將表單命名為scheduleDisplayForm,在jsp中,我使用了名稱“ schedule”。 我需要保留來自struts配置的命名以獲取相同的對象。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM