[英]How do I convert this simple scriptlet to JSTL?
I have the following scriptlet that I'm trying to convert to JSTL 我有以下要转换为JSTL的脚本
<%
String req = request.getParameter("loginfailed");
if(req != null)
{
if(req.equals("true"))
{%>
<h4 id="loginerrormessage">Invalid email address or password.</h4>
<%}
}
%>
This scriptlet works just fine, but I'm trying to convert it to JSTL now which I am new to. 这个scriptlet正常工作,但是我现在尝试将其转换为JSTL,这是我的新手。 This is my best attempt at recreating the logic using JSTL.
这是我使用JSTL重新创建逻辑的最佳尝试。
<c:set var="req" value="${request.getParameter(\"loginfailed\")}"/>
<c:if test="${ req!=null }">
<c:if test="${ req.equals(\"true\") }">
<h4 id="loginerrormessage">Invalid email address or password.</h4>
</c:if>
</c:if>
When I replace the scriptlet with the JSTL I have written above, nothing crashes but I no longer see the "Invalid email address or password." 当我用上面编写的JSTL替换scriptlet时,没有崩溃,但是我不再看到“无效的电子邮件地址或密码”。 when I would have seen it using the scriptlet.
当我使用scriptlet看到它时。 I'm not sure what I'm doing wrong here.
我不确定我在做什么错。
Is it a scope issue? 这是范围问题吗? I figured the default page scope was fine for the c:set.
我认为默认页面范围适合c:set。 Could it have anything to do with the fact that I'm using escape quotes in the JSTL?
它与我在JSTL中使用转义引号有关吗?
just use 只是使用
<c:if test="${ param.loginfailed eq 'true' }">
<h4 id="loginerrormessage">Invalid email address or password.</h4>
</c:if>
here param
is implicit JSP object which gives you access to request parameters. 这里
param
是隐式JSP对象,它使您可以访问请求参数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.