According to TLD or attribute directive in tag file, attribute name does not accept any expressions(根据标记文件中的 TLD 或属性指令,属性名称不接受任何表达式)
问题描述
我在 JSP 中编写了以下代码.
I write the following code in JSP.
<%
String p_loginPassword = OpeCommon.LOGIN_PASSWORD;
String p_encryptCode = OpeCommon.encriptPassword(OpeCommon.KEY_USER_ID, OpeCommon.KEY_USER_PASSCODE);
%>
<s:url id="printURL" action="actMod" method="printout">
<s:param name="<%=OpeCommon.LOGIN_PASSWORD %>"><%=OpeCommon.encriptPassword(OpeCommon.KEY_USER_ID, OpeCommon.KEY_USER_PASSCODE)%></s:param>
</s:url>
显示错误:根据标签文件中的 TLD 或属性指令,属性名称不接受任何表达式
It displays error : According to TLD or attribute directive in tag file, attribute name does not accept any expressions
我该怎么写,请给我一些建议.
How should I write for that, pls give me some suggestions.
推荐答案
不要在struts标签中使用scriptlet,不要在JSP中使用,如果不行你可以试试
Don't use scriptlets in the struts tags, don't use it at all in JSP, if you can't you may try
<s:set var="loginPassword"><%=OpeCommon.LOGIN_PASSWORD %></s:set>
<s:param name="%{#loginPassword}"><%=OpeCommon.encriptPassword(OpeCommon.KEY_USER_ID, OpeCommon.KEY_USER_PASSCODE)%></s:param>
请注意,可以通过 OGNL 表达式访问常量,并且该表达式在 struts 标记中是允许的.但是,它适用于 OGNL 语法,您应该为静态内容提供 FQCN.常量不需要在配置中启用静态访问,但需要调用静态方法.如果您允许静态访问,那么一切都可以通过 OGNL 表达式完成,如果不仅可以访问常量,例如
Note, that constants could be accessed through the OGNL expression, and that expression is allowed in the struts tags. But, it applies to the OGNL syntax and you should supply FQCN to the static content. Constants don't require enabling static access in the configuration, but calling a static method is required. If you allow static access then everything could be done via OGNL expressions, if not only constants could be accessed like
<s:param name="%{@com.package.OpeCommon@LOGIN_PASSWORD}">
这篇关于根据标记文件中的 TLD 或属性指令,属性名称不接受任何表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:根据标记文件中的 TLD 或属性指令,属性名称不接受任何表达式
基础教程推荐
- 多个组件的复杂布局 2022-01-01
- Java 实例变量在两个语句中声明和初始化 2022-01-01
- 验证是否调用了所有 getter 方法 2022-01-01
- 如何在 Spring @Value 注解中正确指定默认值? 2022-01-01
- 大摇大摆的枚举 2022-01-01
- Java Swing计时器未清除 2022-01-01
- 从 python 访问 JVM 2022-01-01
- 在 Java 中创建日期的正确方法是什么? 2022-01-01
- 不推荐使用 Api 注释的描述 2022-01-01
- 如何在 JFrame 中覆盖 windowsClosing 事件 2022-01-01
