http://www.javaresearch.org/forum/thread.jsp?column=20&thread=2281&start=0&msRange=151. ApplicationResources.properties support the establishment of a Chinese ApplicationResources_ISO.properties file, the application with the message written in, then execute this command in dos, this will convert native2ascii -encoding gb2312 ApplicationResources_ISO.properties ApplicationResources.properties ISO-coded into ApplicationResources GB2312 encoding format, and at the same time to save ApplicationResources.properties.native2ascii this tool comes with a jdk East East, so if the PATH is set correctly, you can run directly, you can find him under $ java_home $ / bin. The conversion is similar to this like ISO format: tj.type = commodity vehicle type GB2312 format: tj.type = / u5546 / u54c1 / u8f66 / u7c7b / u578b then set this resource file in Struts-Config.xml
Plus Filter that sets the character encoding to be used in parsing the * incoming request, either unconditionally or only if the client did not * specify a Character Encoding. Configuration of this filter is based on * The folowing initialization parameters: p> * *
ignore code> initialization parameter This parameter * is required, so there is no default.. li> *
selectencoding ()
selectencoding ()
SELECTENCODING Code> Method is set. if set to "false, *
SelectEncoding () code> is caled Only strong> if the * client HAS NOT ALREADY Specified An Encoding. by Default, this * Parameter is set to "true". li> * ul> * * Although this filter can be used unchanged, it is also easy to * subclass it and make the } / ** * Select and set (if specified) the character encoding to be used to * interpret request parameters for this request. * * @Param request The servlet request we are processing * @param result The servlet response we are creating * @ param chain The filter chain we are processing * * @exception IOException if an input / output error occurs * @exception ServletException if a servlet error occurs * / public void doFilter (ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {/ / Conditionally select and set the character encoding to be used if (ignore || (request.getCharacterEncoding () == null)) {String encoding = selectEncoding (request); if (! encoding = null) request.setCharacterEncoding (encoding); } // Pass Control on to the next filter chain.dofilter (request, response);} / ** * place . This filter into service * * @param filterConfig The filter configuration object * / public void init (FilterConfig filterConfig) throws ServletException {this.filterConfig = filterConfig; this.encoding = filterConfig.getInitParameter ( "encoding"); String value = filterConfig. GetInitParameter ("ignore"); if (value == null) this.Ignore = true; Else IF (Value.equalsignoreCase ("true") this.Ignore = true; Else IF (Value.Equalsignorecase ("YES"))) ignore = true; else this.ignore = false; selectEncoding () code> method more * intelligent about what encoding to choose, based on characteristics of * the INCOMING Request (Such As the Values of the
Accept-language code> * and
user-agent code> headers, or a value stashed in the current * user's session. p> * * @Author John wong * @version $ ID: setcharacterencodingfilter.java, v 1.1 2002/04/10 13:59:27 Johnwong Exp $ * / Public class setcharacterencodingfilter imports filter {// ------------------------------------------ ----------- Instance variables / ** * The default character encoding to set for reviews That pass throgh * this filter. * / Protected String Encoding = null; / ** * The filter configuration object we are associated with If this value * is null, this filter instance is not currently configured * / protected FilterConfig filterConfig = null;.. / ** * Should a character encoding specified by the client BE IGNORED? * / protected boilean ignore = true; // ------------------------------------- -------------------- Public Methods / ** * Take this filter out of service. * / Public void destroy () {this.encoding = null; this.filterconfig = NULL;