Bud*_*dhi 5 spring jsp javabeans
我已经配置了这样的bean,我在文件中正确地有了forum.host.url
<bean id="forum_host_url" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="forum.host.url"/>
<property name="resourceRef" value="true"/>
</bean>
Run Code Online (Sandbox Code Playgroud)
我需要从JSP访问这个bean值,我试过了
${forum_host_url}
Run Code Online (Sandbox Code Playgroud)
在我的jsp文件中但它没有获得任何值.什么是正确的方法?
如果您正在使用,InternalResourceViewResolver您可以这样做:
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
<property name="prefix" value="/WEB-INF/views/"/>
<property name="suffix" value=".jsp"/>
<property name="exposedContextBeanNames">
<list><value>forum_host_url</value></list>
</property>
</bean>
Run Code Online (Sandbox Code Playgroud)
如果您愿意,可以使用exposeContextBeansAsAttributes属性,JSP将能够访问您的所有bean.
| 归档时间: |
|
| 查看次数: |
2891 次 |
| 最近记录: |