主要有這么幾步,在spring web 的 [sevlet-name]-servlet.xml文件中,修改為:
黑體字體為關鍵,其它根據你的實際情況配置:
<!-- ========================= VIEW DEFINITIONS ========================= -->
<bean id="velocityViewResolver" class="org.springframework.web.servlet.view.velocity.VelocityViewResolver">
<property name="suffix" value=".vm"></property>
<property name="contentType"><value>text/html;charset=UTF-8</value></property>
</bean>
<bean id="velocityConfigurer" class="org.springframework.web.servlet.view.velocity.VelocityConfigurer">
<property name="resourceLoaderPath">
<value>${pgallery.template}</value>
</property>
<property name="velocityProperties">
<props>
<prop key="input.encoding">utf-8</prop>
<prop key="output.encoding">utf-8</prop>
</props>
</property>
</bean>
注:
首先要保證開發環境的文件編碼統一,將jsp/html的字符編碼都聲明為utf-8。