在java web项目中,我的前台不是用jsp写的,而是用velocity,发现显示中文时会乱码。
解决方法:
在application-cortext.xml中加入以下这部分就可以了:
<bean id="velocityConfigurer" class="org.springframework.web.servlet.view.velocity.VelocityConfigurer">
<property name="resourceLoaderPath">
<value>/WEB-INF/view/</value>
</property>
<property name= "velocityProperties">
<props>
<prop key= "input.encoding">UTF-8</prop>
<prop key= "output.encoding">UTF-8</prop>
</props>
</property>
</bean>