java使用spring:eval在jsp中显示属性值
我正在寻找在jsp文件中显示Spring属性值的帮助
我发现了一个链接,它与我的要求相同。 单击Using spring:eval inside hasRole
我正在使用Spring 2.5
这是我的applicationContext util。xml文件:
xmlns:util="http://www.springframework.org/schema/util"
xmlns:context="http://www.springframework.org/schema/context"
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
<util:properties id="viewPropertyConfigurer" location="classpath:conf/app_config.properties"/>
<context:property-placeholder properties-ref="viewPropertyConfigurer" />
在我的菜单上。jsp
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<spring:eval expression="@viewPropertyConfigurer.getProperty('role.admin')" />
在lib文件夹中,我还有spring-web-2.5.6。jar文件,以确保eval在jsp中正常工作。但我不确定添加spring:eval标记后会出现什么问题,jsp根本没有加载它抛出的标记
[ERROR,context.JspTilesRequestContext,http-8080-1] -[UID=galips - SessionID=691A896E807850568DF9B0F5356F6CB2] - JSPException while including path '/WEB-INF/jsp/menu.jsp'.
在我的应用程序中,我也在使用servlet过滤器,希望这不会成为一个问题
提前谢谢你的帮助
# 1 楼答案
据我所知
EvalTag
是在Spring3(@since 3.0.1
)中添加的。如果您使用的是Spring2.5,那么您没有<spring:eval>
支持可能的解决办法:
更新(选项2示例):
然后,您需要在处理程序映射中配置此拦截器