Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/88.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在所有jsp中显示下拉选择的值_Javascript_Jquery_Html_Angularjs_Jsp - Fatal编程技术网

Javascript 在所有jsp中显示下拉选择的值

Javascript 在所有jsp中显示下拉选择的值,javascript,jquery,html,angularjs,jsp,Javascript,Jquery,Html,Angularjs,Jsp,我有一个header.jsp,下拉框为“Role”.header.jsp通过include指令在所有其他jsp中使用。登录后,登录页为主页。用户需要从下拉框中选择一个值,并在此基础上显示一些页面。问题是,当从列表中选择任何其他jsp时,将刷新从下拉框中选择的值。全部静态数据被正确地传递给其他JSP。该值如何在整个过程中保持不变 <div class='header'> <div class='top_header text-center'>

我有一个header.jsp,下拉框为“Role”.header.jsp通过include指令在所有其他jsp中使用。登录后,登录页为主页。用户需要从下拉框中选择一个值,并在此基础上显示一些页面。问题是,当从列表中选择任何其他jsp时,将刷新从下拉框中选择的值。全部静态数据被正确地传递给其他JSP。该值如何在整个过程中保持不变

<div class='header'>    
    <div class='top_header text-center'>
        <span>Welcome:</span>
        <c:out value="${sessionScope.displayName}" />
        &nbsp;|&nbsp; <span>Role:</span>                        
        <select id="role" class="role_select" name="role" onchange="submitRole(this);">
            <option id="roleOption" value="Select Role">Select Role</option>
        <c:forEach var="role" items="${sessionScope.role}">                     
            <option value='${role}'>                    
                <c:out value="${role}"/>
                <c:set var="SelectRole" scope="session" value="${role}" />                  
            </option>
        </c:forEach>                        
        </select>

        &nbsp;|&nbsp; <span><a href='logout'>Logout</a></span> <span>
            <c:if test="${not empty error}">
                <div>${error}</div>
            </c:if> <c:if test="${not empty message}">
                <div>${message}</div>
            </c:if>
        </span>
    </div>

    <div class='container'>
        <div class='pull-left col-lg-6 col-md-6 col-sm-6 col-xs-6'>
            <span>Feedback System</span>
        </div>
    </div>
 </div>

欢迎:
|角色:
选择角色
|   
${error}
${message}
反馈系统
您必须读取所选角色的值,并将其设置到request.setAttribute(“SelectRole”、“value”)中
或者在session.setAttribute(“SelectRole”、“value”)中,并在选项标记中执行以下操作
${role}
您必须读取所选角色的值,并将其设置到request.setAttribute(“SelectRole”、“value”)中
或者在session.setAttribute(“SelectRole”、“value”)中,并在选项标记中执行以下操作
${role}

谢谢。这是有效的,但在实现此功能后,登录页面时未选择默认选项值(选择角色)。请按以下代码
选择角色${Role}
添加默认值${Role}在空白处添加默认值。谢谢。这是有效的,但在实现此操作后,登录页面时未选择默认选项值(选择角色)。请按以下代码Select Role${Role}添加默认值${Role}在空白处添加默认值。
You have to read that value of the selected role and and set it into either the request.setAttribute("SelectRole", "value")
or in session.setAttribute("SelectRole", "value") and in the option tag do the following

<option value="${role}" ${role == SelectRole?'selected="selected"':''}>${role}</option>