首页 文章

会话变量未加载密码

提问于
浏览
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>

实际发生的情况是,当用户登录时,用户名和密码被设置为具有其值的会话变量 . 现在用户可以做任何他想要的更新配置文件,显示配置文件等 . 现在我想要的是当用户点击主页时,用户的主页必须出现,即用户登录时出现的页面 . 该页面被命名为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包含通过用户历史记录操作发出的一些动态内容 . 我希望在点击主页时也加载内容 . 现在发生的事情是用户单击home,然后使用我发送的查询字符串调用action login.action,对应于click,如“menubaruser.jsp”所示,但显示的o / p是它没有加载密码字段 . 它返回“输入”,显示密码的服务器端验证错误为“需要密码” .

要呈现的所需jsp名为loginSuccess.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中的Home时,我希望调用“login”,并使用用户名和密码的值来设置会话中存在的值 . 如果这成功发生,则由于操作链接,将调用“userhistory”操作并显示带有所需数据的loginSuccess.jsp .

问题是,当我发送带有用户名和密码值的查询字符串时,它不设置密码的值,它将密码设置为空,因此返回“input”,它使用actionerror“Password empty”呈现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>

请帮忙......

1 回答

  • 0

    根据我在上面的帖子中的理解,您正在尝试将value属性设置为密码类型 .

    由于某些安全问题,这是不可能的 .

    您可以使用文本框并使用一些java脚本代码来更改输入类型中显示的字符的可见性 .

相关问题