2013-10-14 48 views
2

這個問題有點長,但我覺得它很有趣。請看看plz。 我有一個名爲「Menubaruser.jsp」 JSP如下:會話變量不能加載密碼

<%@ taglib prefix="sj" uri="/struts-jquery-tags"%> 
<%@ taglib prefix="s" uri="/struts-tags"%> 
    <div id='cssmenu'> 
      <ul> 
       <s:url id="userhome" value="/login.action?login.username=%{#session.username}&login.password=%{#session.password}"></s:url> 
       <li><sj:a id="user_home" href="%{userhome}" targets="mainContent"><span>Home</span></sj:a></li> 
       <%-- <li><s:a action="#"><span>Home</span></s:a></li> --%> 

       <s:url id="showProfile" value="/profile.action"></s:url> 
       <li><sj:a id="profile_show" href="%{showProfile}" targets="mainContent"><span>Show Profile</span></sj:a></li> 

       <s:url id="editProfile" value="/editProfileLink.action"></s:url> 
       <li><sj:a id="profile_edit" href="%{editProfile}" targets="mainContent"><span>Update Profile</span></sj:a></li> 

       <s:url id="signout" value="/logout.action"></s:url> 
       <li><sj:a id="signout" href="%{signout}" targets="mainContent"><span>Sign Out</span></sj:a></li> 
       <%-- <li class='last'><s:a action="#"><span>Contact Us</span></s:a></li> --%> 
      </ul> 
    </div> 

什麼實際發生的是,當用戶登錄,用戶名和密碼設置爲與他們的價值觀會話變量。現在用戶可以做任何他想要更新配置文件,顯示配置文件等。現在我想要的是當用戶點擊home時,用戶的主頁必須出現,即用戶登錄時出現的頁面。該頁面被命名爲loginSuccess。 jsp和它被打開對應於login.action如圖以下struts.xml中:

<action name="login" class="com.view.LoginAction" method="checkLogin"> 
     <result name="input">/loginPage.jsp</result> 
     <result name="loginSuccessUser" type="chain">userHistory</result> 
     <result name="loginSuccessAdmin">/loginSuccessAdmin.jsp</result> 
     <result name="loginClicked">/loginPage.jsp</result> 
    </action> 
    <action name="userHistory" class="com.view.HistoryAction" method="UserHistory"> 
      <result name="showHistory">/loginSuccess.jsp</result> 
    </action> 

loginSuccess.jsp含有自帶通userhistory動作一些動態內容。我希望的是當點擊home時,內容也會被加載。 現在發生的事情是當用戶點擊home時,然後調用login.action與我發送的查詢字符串相對應的點擊,如「menubaruser.jsp」所示,但顯示的o/p是它沒有加載密碼字段。它返回「輸入」,顯示密碼的服務器端驗證錯誤爲「需要密碼」。

被渲染名爲loginSuccess.jsp和編碼爲所需的JSP如下:

<%@ taglib prefix="s" uri="/struts-tags"%> 
     <jsp:include page="menubaruser.jsp"></jsp:include> 
     <div style="width:898px"><br><center>Welcome Mr. <b><s:property value="#session.name"/> </b></center> </div> 
     <div id="ajaxdiv"> 
     <div id="ContentLeft"> 
      <jsp:include page="search.jsp"></jsp:include> 
     </div> 
     <div id="contentRight"> 
      <jsp:include page="topdeals.jsp"></jsp:include> 
     </div> 
     </div> 
     <br> 
     <div> 
      <jsp:include page="userHistoryWidget.jsp"></jsp:include> 
     </div>  

UserHistoryWidget.jsp如下:

<%@ taglib prefix="s" uri="/struts-tags"%> 
<%@ taglib prefix="sj" uri="/struts-jquery-tags"%> 

    <div id="searchHeaderHistory">Booking History</div> 
    <div class="CSSTableGenerator"> 
     <table> 
      <colgroup> 
       <col span="1" style="width: 5%;"> 
       <col span="1" style="width: 10%;"> 
       <col span="1" style="width: 8%;"> 
       <col span="1" style="width: 15%;"> 
       <col span="1" style="width: 15%;"> 
       <col span="1" style="width: 6%;"> 
       <col span="1" style="width: 6%;"> 
       <col span="1" style="width: 17%;"> 
       <col span="1" style="width: 18%;"> 
      </colgroup> 

      <tr> 
       <td>Ticket ID</td> 
       <td>Booking Date</td> 
       <td>Flight ID</td> 
       <td>From</td> 
       <td>To</td> 
       <td>Total Fare</td> 
       <td>Net Fare</td> 
       <td></td> 
       <td></td> 
      </tr> 

      <s:iterator value="ticketsList" var="ticket" status="stat"> 

       <tr> 
        <td align="center"><s:property value="#ticket.tid" /></td> 
        <td align="center"><s:property value="#ticket.bookingdate" /></td> 
        <td align="center"><s:property 
          value="#ticket.scheduleDetails.flightDetails.fid" /></td> 

        <s:if test="#ticket.flag==3"> 
         <td><s:property 
           value="#ticket.scheduleDetails.flightDetails.routeDetails.via" /><br> 
          <s:property value="#ticket.scheduleDetails.via_dep_date" />&nbsp;<s:property 
           value="#ticket.scheduleDetails.via_dep_time" />hrs</td> 
        </s:if> 
        <s:if test="#ticket.flag==1 ||#ticket.flag==2||#ticket.flag==4"> 
         <td><s:property 
           value="#ticket.scheduleDetails.flightDetails.routeDetails.source" /><br> 
          <s:property value="#ticket.scheduleDetails.source_dep_date" />&nbsp;<s:property 
           value="#ticket.scheduleDetails.source_dep_time" />hrs</td> 
        </s:if> 
        <s:if test="#ticket.flag==1 ||#ticket.flag==2||#ticket.flag==3"> 
         <td><s:property 
           value="#ticket.scheduleDetails.flightDetails.routeDetails.destination" /><br> 
          <s:property value="#ticket.scheduleDetails.dest_arr_date" />&nbsp;<s:property 
           value="#ticket.scheduleDetails.dest_arr_time" />hrs</td> 
        </s:if> 
        <s:if test="#ticket.flag==4"> 
         <td><s:property 
           value="#ticket.scheduleDetails.flightDetails.routeDetails.via" /><br> 
          <s:property value="#ticket.scheduleDetails.via_arr_date" />&nbsp;<s:property 
           value="#ticket.scheduleDetails.via_arr_time" />hrs</td> 
        </s:if> 
        <td align="center"><s:property value="#ticket.fare" /></td> 
        <td align="center"><s:property value="#ticket.dealFare" /></td> 
        <td style="width: 150px" align="center"> 
         <s:url id="getPassengers" value="/getPassengers.action"> 
          <s:param name="Tid" value="#ticket.tid" /> 
         </s:url> 
         <sj:a id="link_%{#stat.index}" href="%{getPassengers}" targets="ajaxdiv" cssClass="orangebuttonsmall"> 
           View Details  
         </sj:a> 
        </td> 
        <td style="width: 150px" align="center"> 
         <s:a action="cancel" id="button1" style="float:left" cssClass="orangebuttonsmall">Cancel Ticket 
          <s:param name="Tid" value="#ticket.tid"></s:param> 
         </s:a> 
        </td> 
       </tr> 
      </s:iterator> 

     </table> 
    </div> 

現在我想是每當這個loginSuccess .jsp打開userHIstoryWidget.jsp內容被加載。因此,當我在menubaruser.jsp中單擊主頁時,我想要使用用戶名和密碼的值調用「登錄」以使用會話中存在的值進行設置。如果這種情況成功發生,那麼由於操作鏈接,「userhistory」操作被調用並顯示loginSuccess.jsp所需的數據。

問題是,當我發送帶有用戶名和密碼值的查詢字符串時,它沒有設置密碼的值,並且它將密碼設置爲空,因此返回「輸入」,它使用actionerror呈現loginPage.jsp「密碼空」。 我也嘗試發送一個常量值而不是密碼中的會話值,但問題仍然存在。它設置用戶名的值,但輸入密碼失敗。

LoginPage.jsp如下:

<%@ taglib prefix="s" uri="/struts-tags"%> 
      <%@ taglib prefix="sj" uri="/struts-jquery-tags"%> 
      <jsp:include page="menubar.jsp"></jsp:include> 
      <br><br><br><br><br><br>    
      <s:form action="login" method="post" theme="css_xhtml" cssClass="form1" style="margin:0 211px"> 
       <div class="searchHeader">LOGIN</div> 
       <div id="error"> 
        <s:property value="errormsg"/> 
       </div> 
       <s:textfield label="Username" name="login.username" /> 
       <s:textfield label="Password" name="login.password" /> 
       <div class="submitButton"> 
        <sj:submit value="SUBMIT" targets="mainContent"/> 
       </div> 
      </s:form> 

請幫助...

+0

將'escapeAmp =「false」'添加到''。 –

+0

@AleksandrM什麼都沒有發生先生..發生同樣的錯誤。它不會通過我在查詢字符串中傳遞的內容替換密碼字段的值。即使我傳遞一個恆定的值,它也不會接受它。無論什麼,密碼屬性都保留爲空,因此返回輸入。 –

+0

顯示呈現的HTML。 –

回答

0

按照從上面的帖子我的理解你正在嘗試設置值屬性的密碼類型。

由於某些安全問題,這是不可能的。

您可以使用文本框並使用一些java腳本代碼來更改輸入類型中顯示的字符的可見性。