本文介绍了Struts逻辑标记等于不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

非常快速的问题.有人可以向我解释为什么此代码不起作用吗?

Very quick questions.Could someone explain to me why this code does not work?

<%@ taglib prefix="logic"   uri="/WEB-INF/struts-logic.tld" %>

<%
    int myValue= 2;
%>

myValue: <%=myValue%>
<br/>
<logic:equal name="myValue" value="2" scope="session">
    logic:equal works!
</logic:equal>

即使我将myValue更改为String仍然不起作用

Even if I change myValue to a String is still doesn't work

非常令人沮丧,因为我知道这将是显而易见的.

Quite frustrating, cause I know it's going to be something obvious.

预先感谢

KS

工作示例!

<%@ taglib prefix="logic" uri="/WEB-INF/struts-logic.tld" %>

<%
    request.setAttribute("myValue", 2);
%>

myValue - <%=request.getAttribute("myValue")%>]]

<br/>
<logic:equal name="myValue" value="2" scope="request">
    logic:equal works!
</logic:equal>

推荐答案

<logic:equal name="myValue" value="2" scope="session">

此标记查找名为"myValue"的会话属性.不适用于名为"myValue"的局部变量.

This tag looks for a session attribute named "myValue". Not for a local variable named "myValue".

真正的问题是:为什么要使用标记为不赞成使用JSTL的标记库,而该库是正式废弃的框架的一部分?

The real question is: why are you using a tag library which is marked as deprecated in favor of the JSTL, this library being part of a framework which is officially abandoned?

这篇关于Struts逻辑标记等于不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-25 01:47