wicket 乱码 wicket乱码
程序员文章站
2022-03-09 14:04:25
...
使用wicket,有时会莫名的乱码,最好方法是在以下所有地方都统一成UTF-8:
1.如果保用mysql数据库,要使数据库,表的字符集都为utf8;
2.如果用spring,在web.xml中加入:
<filter>
<filter-name>characterEncodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>characterEncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
3.在tomcat的server.xml中的Connector节点加入:URIEncoding="UTF-8"
4.在wicket的webapplication的init方法中加入:
this.getMarkupSettings().setDefaultMarkupEncoding("UTF-8");
1.如果保用mysql数据库,要使数据库,表的字符集都为utf8;
2.如果用spring,在web.xml中加入:
<filter>
<filter-name>characterEncodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>characterEncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
3.在tomcat的server.xml中的Connector节点加入:URIEncoding="UTF-8"
4.在wicket的webapplication的init方法中加入:
this.getMarkupSettings().setDefaultMarkupEncoding("UTF-8");