Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/fortran/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
Java jsp中菜单的条件逻辑。。。_Java_Html_Jsp_Jstl - Fatal编程技术网

Java jsp中菜单的条件逻辑。。。

Java jsp中菜单的条件逻辑。。。,java,html,jsp,jstl,Java,Html,Jsp,Jstl,我有index.jsp页面 <form action="LoginServlet" method="post"> <fieldset style="width: 300px"> <legend> Login to App </legend> <table> <tr> <td>User ID<

我有index.jsp页面

 <form action="LoginServlet" method="post">  
    <fieldset style="width: 300px">  
        <legend> Login to App </legend>   
        <table>  
            <tr>  
                <td>User ID</td>  
                <td><input type="text" name="Emp_id" required="required" /></td>  
            </tr>  
            <tr>  
                <td>Password</td>  
                <td><input type="password" name="Pwd" required="required" /></td>  
            </tr> 
           <tr>  
                <td>User Type</td>  
                <td> <select name="usertype">
                <option>Employee</option>
                <option>Manager</option>
                <option>Admin</option>
            </select></td>   
            </tr>
            <tr>  
                <td><input type="submit" value="Login" /></td>  
            </tr>  
        </table>  
    </fieldset>  
</form>  

登录应用程序
用户ID
密码
用户类型
雇员
经理
管理
header.jsp: 当用户以usertype作为“Employee”登录时,在下一页的头文件中只能显示两个菜单选项。如果usertype是“Admin”或“Manager”,那么它必须显示所有四个菜单选项

<body>
    <form name="headerform" action="Get">
    <c:choose>
     <c:when test="${usertype== Employee}">
        <div class="nav">      
            <ul><li class="container"><img src="${pageContext.request.contextPath}/images/enabling.jpg" /></li>
            <li class="current"><a href="daywise.jsp">DayWise TimeSheet</a></li>
            <li><a href="timesheet.jsp">Weekly TimeSheet</a></li>
            </ul>
        </div>
     </c:when>
     <c:when test="${usertype== Manager}">
        <div class="nav">      
            <ul><li class="container"><img src="${pageContext.request.contextPath}/images/enabling.jpg" /></li>
            <li class="current"><a href="daywise.jsp">DayWise TimeSheet</a></li>
            <li><a href="timesheet.jsp">Weekly TimeSheet</a></li>
            <li><a href="newemployee.jsp">Add New Employeer</a></li>
            <li><a href="retrieve.jsp">Retrieve TimeSheet</a></li>
            </ul>
        </div>
     </c:when>
     <c:when test="${usertype== Admin}">
         <div class="nav">      
            <ul><li class="container"><img src="${pageContext.request.contextPath}/images/enabling.jpg" /></li>
            <li class="current"><a href="daywise.jsp">DayWise TimeSheet</a></li>
            <li><a href="timesheet.jsp">Weekly TimeSheet</a></li>
            <li><a href="newemployee.jsp">Add New Employeer</a></li>
            <li><a href="retrieve.jsp">Retrieve TimeSheet</a></li>
            </ul>
        </div>
     </c:when>
     <c:otherwise>
        <div class="nav">      
            <ul><li class="container"><img src="${pageContext.request.contextPath}/images/enabling.jpg" /></li>
            <li class="current"><a href="daywise.jsp">DayWise TimeSheet</a></li>
            <li><a href="timesheet.jsp">Weekly TimeSheet</a></li>
            </ul>
        </div>
     </c:otherwise>
    </c:choose>
    </form>
</body>


但是从上面的代码中,只有员工选项可见。。。我是第一次使用jstl,所以请告诉我怎么做。或者是否有其他方法根据usertype隐藏选项。Index.jsp与header.jsp不同。从index.jsp中,用户类型值必须转到其他jsp页面的header.jsp。

您确定该员工可见吗?
选项是否为

您的情况不正确,请尝试在以下方面进行更改:

 <c:when test="${usertype eq 'Employee'}">


使用
eq
标记,而不是使用
==
@VivekSingh感谢您的回复,但我尝试了。。。不是吗working@BalusC我不知道它是如何重复的。请在单引号内使用
员工、经理和管理员
,即
“员工”、“经理”和“管理员”
@VivekSingh非常感谢。。。它起作用了!!谢谢你的快速回复。。。是的,我肯定不是这样的。您首先测试了usertype的值是什么?(这是我在本例中调试的简单方法)是的。。。我已检查它是否显示正确的用户类型