Web application developers often use UTF-8 as the encoding in their applications, but fail to change the server defaults. This applies to anything which uses Servlets (including JSP, and JSF). You can change the defaults in the sun-web.xml, or glassfish-web.xml as shown below by setting the parameter-encoding element. This remove a number of default encoding warnings like this:
WARNING: WEB0500: default-locale attribute of locale-charset-info element is being ignored WARNING: PWC4011: Unable to set request character encoding to UTF-8 from context /, because request parameters have already been read, or ServletRequest.getReader() has already been called.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | <? xml version = "1.0" encoding = "UTF-8" ?> <!DOCTYPE glassfish-web-app PUBLIC "-//GlassFish.org//DTD GlassFish Application Server 3.1 Servlet 3.0//EN" < glassfish-web-app error-url = "" > < class-loader delegate = "true" /> < jsp-config > < property name = "keepgenerated" value = "true" > < description >Keep a copy of the generated servlet class' java code.</ description > </ property > </ jsp-config > <!-- Change the default character encoding from ISO-8859-1 to UTF-8 --> < parameter-encoding default-charset = "UTF-8" /> </ glassfish-web-app > |
2 comments :
Thanks great
Funciona, muchas gracias, a sido de gran utilidad.
Post a Comment