欢迎光临
我们一直在努力

JSTL+Spring+Hibernate中文乱码问题解决-JSP教程,Java技巧及代码

建站超值云服务器,限时71元/月

web.xml中加入:

<filter> <filter-name>setcharacterencoding</filter-name> <filter-class>org.springframework.web.filter.characterencodingfilter</filter-class> <init-param> <param-name>encoding</param-name> <param-value>big5</param-value> </init-param> </filter>

<filter-mapping> <filter-name>setcharacterencoding</filter-name> <url-pattern>*.jsp</url-pattern> </filter-mapping>

*-servlet.xml中加入:

<bean id="viewresolver" class="org.springframework.web.servlet.view.internalresourceviewresolver"> <property name="viewclass"> <value>org.springframework.web.servlet.view.jstlview</value> </property> <property name="prefix"> <value>/web-inf/jsp/</value> </property> <property name="suffix"> <value>.jsp</value> </property> <property name="contenttype"> <value>text/html;charset=big5</value> </property> </bean>

*.jsp文件中添加:

<% @page contenttype="text/html;charset=big5"%>

<meta http-equiv="content-type" content="text/html; charset=big5">

注:当时我采取以上办法,却仍未能完全解决乱码问题,因为我用的類是extends simpleformcontroller,我猜測是在person person = (person) cmd;時就已亂碼,經測試果然如此,於是,在其後加了一個處理,person.setpname(new string(person.getpname().getbytes(),"big5"));就可以正確的存入繁體中文~~~

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » JSTL+Spring+Hibernate中文乱码问题解决-JSP教程,Java技巧及代码
分享到: 更多 (0)

相关推荐

  • 暂无文章