我有下一个豆子:
@Component
@ComponentScan("es.pys.model")
@Scope(value = WebApplicationContext.SCOPE_SESSION, proxyMode = ScopedProxyMode.TARGET_CLASS)
public class Sesion {
private Long id;
private String name;
}
我在几个控制器中使用。
@Autowired
private Sesion sesion;
我也想在我的视图中使用它(示例):
<spring:message code="welcome" arguments="${fn:escapeXml(sesion.name)}" htmlEscape="false"/>
问题是之前的行不起作用,因为sesion
不存在。
如何在我的所有视图中访问我的 bean,并且只有这个 bean ?我一直在阅读解决方案,例如:
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="exposedContextBeanNames">
<list>
<value>sesion</value>
</list>
</property>
</bean>
问题是我需要定义我的 beanapplicationContext.xml
而不是使用注释,还是我错了?
想法?
谢谢!。