springMVC + velocity

java.lang.ClassNotFoundException: org.springframework.web.servlet.view.velocity.VelocityConfigurer

 

这个问题加入 spring-context-support-3.2.2.RELEASE.jar 就OK了

 

velocity eclipse插件

https://code.google.com/p/veloeclipse/

<bean id="velocityConfig"
		class="org.springframework.web.servlet.view.velocity.VelocityConfigurer"
		p:resourceLoaderPath="/WEB-INF/velocity/" />
<!-- 		p:configLocation="classpath:common/velocity.properties" /> -->

	<bean id="viewResolver"
		class="org.springframework.web.servlet.view.velocity.VelocityViewResolver"
		p:suffix=".vm" />

 SpringMVC + velocity获得requset session的问题

首先,要在 org.springframework.web.servlet.view.velocity.VelocityViewResolver 里把

request/session 暴露出来:

扫描二维码关注公众号,回复: 646296 查看本文章
p:exposeRequestAttributes="true"
p:exposeSessionAttributes="true"
 

然后,就可以页面上拿到你在java code 里 set 的 attribute :

如:

request.setAttribute("now",new Date());
session.setAttribute("now2",new Date());

 

在页面上直接拿就好了,不需要再用request.xxx 因为上面的两个true 会把request session 里的数据merge到context 里 ,

$now
$now2

猜你喜欢

转载自k1280000.iteye.com/blog/2034824