Note: Eclipse rap rich client Development Summary-a series of articles are transplanted from my iteye blog. Later will directly update the http://jlins.iteye.com/
1. solve the issue of garbled rap character sets
Character Set Problem, solution: Add in plugin. XML-build. Properties
Javacdefaultencoding .. = UTF-8 to solve Character Set garbled
2. Solve the Problem of garbled Web Front-end input
Use traditional character set Filters
Write a filter class
<span style="font-size: small;">public class CharacterEncodingFilter implements Filter{ private String edcoding; private FilterConfig filterConfig; private boolean ignore; public CharacterEncodingFilter() { this.edcoding = null; this.filterConfig = null; this.ignore = true; } public void destroy() { this.edcoding = null; this.filterConfig = null; } public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException, ServletException { if ((this.ignore) || (request.getCharacterEncoding() == null)) { String encoding = setCharacterEncoding(request); if (encoding != null) request.setCharacterEncoding(encoding) } filterChain.doFilter(request, response); } public void init(FilterConfig filterConfig) throws ServletException { this.filterConfig = filterConfig; this.edcoding = filterConfig.getInitParameter("encoding"); String value = filterConfig.getInitParameter("ignore"); if (value == null) this.ignore = true; else if (value.equalsIgnoreCase("true")) { this.ignore = true; } else this.ignore = false; } public String setCharacterEncoding(ServletRequest request) { return this.edcoding; }}</span>
Then the jar package method is reached under the war/web_inf/lib directory.
Add in Web. xml
When rap exports a war package, encoding problems are handled. The character filter processing method is added.
1. After exporting the war, modify the Web. xml file in the war package and add a filter.
The content is as follows:
<span style="font-size: small;"><span> <filter> <filter-name>CharacterEncodingFilter</filter-name> <filter-class>com.encoding.CharacterEncodingFilter</filter-class> <init-param> <param-name>encoding</param-name> <param-value>UTF-8</param-value> </init-param> </filter> <filter-mapping> <filter-name>CharacterEncodingFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping></span></span>
2. Add a jar package
Add the jar package [encoding. jar] used by the filter to the Lib of the exported war package. After the war package is loaded, you can find the classes used by the filter.
The above two parts can perfectly solve Chinese problems