Jsp <;c:当测试=时${action==view}"&燃气轮机;从不使用?action=view在URL上计算true
我有以下代码:Jsp <;c:当测试=时${action==view}"&燃气轮机;从不使用?action=view在URL上计算true,jsp,jstl,el,Jsp,Jstl,El,我有以下代码: <%@ page language="java" session="true" contentType="text/html" pageEncoding="UTF-8"%> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <% request.setAttribute("action", request.getParameter("action")); %>
<%@ page language="java" session="true" contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
request.setAttribute("action", request.getParameter("action"));
%>
<c:choose>
<c:when test="${action == null}">
NULL
</c:when>
<c:when test="${action == view}">
VIEW
</c:when>
</c:choose>
无效的
看法
但是,当我通过?action=view
传递URL时,它不会显示view
我哪里出错了?EL表达式
${view}
正在页面、请求、会话或应用程序范围中查找该名称上的属性,就像${action}
的工作方式一样。但是,您打算将其与字符串进行比较。然后应该使用引号使其成为真正的字符串变量,如so${'view'}
。它在普通Java代码中也是这样工作的
<c:choose>
<c:when test="${action == null}">
NULL
</c:when>
<c:when test="${action == 'view'}">
VIEW
</c:when>
</c:choose>
这样你就可以去掉整行代码了
另见:
<c:choose>
<c:when test="${param.action == null}">
NULL
</c:when>
<c:when test="${param.action == 'view'}">
VIEW
</c:when>
</c:choose>