根据标记文件中的 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}">
相关文章