Should also mention, Struts 2 will set the character encoding for you via the "struts.i18n.encoding" setting. This can be set either as an init-param to the Struts 2 filter, in /WEB-INF/classes/struts.properties, or in your struts.xml. See http://struts.apache.org/2.x/docs/configuration-files.html for more information.
Don On 12/13/06, Don Brown <[EMAIL PROTECTED]> wrote:
You need two <filter-mapping> elements, and I'd put your filter first. Change: <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> <filter-name>Set Character Encoding</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> To: <filter-mapping> <filter-name>Set Character Encoding</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <filter-mapping> <filter-name>struts2</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> Don On 12/13/06, red phoenix <[EMAIL PROTECTED]> wrote: > I have a filter configure question about struts2,i want to filter character > code in web.xml file,I know how to configure it in struts 1.3, > C:\tomcat\webapps\exercise\WEB-INF\web.xml > ... > <filter> > <filter-name>Set Character Encoding</filter-name> > <filter-class>filters.SetCharacterEncodingFilter</filter-class> > <init-param> > <param-name>encoding</param-name> > <param-value>gb2312</param-value> > </init-param> > </filter> > > <filter-mapping> > <filter-name>Set Character Encoding</filter-name> > <url-pattern>/*</url-pattern> > </filter-mapping> > > In struts 1.3,it runs well.Now I want to configure it again under struts2.0,I > read struts2.0 web.xml configure,it's content like follows: > <filter> > <filter-name>struts2</filter-name> > <filter-class>org.apache.struts2.dispatcher.FilterDispatcher > </filter-class> > </filter> > > <filter-mapping> > <filter-name>struts2</filter-name> > <url-pattern>/*</url-pattern> > </filter-mapping> > > Then I add my configure into C:\tomcat\webapps\exercise\WEB-INF\web.xml,like > follows; > <filter> > <filter-name>struts2</filter-name> > <filter-class>org.apache.struts2.dispatcher.FilterDispatcher > </filter-class> > > <filter-name>Set Character Encoding</filter-name> > <filter-class>filters.SetCharacterEncodingFilter</filter-class> > <init-param> > <param-name>encoding</param-name> > <param-value>gb2312</param-value> > </init-param> > </filter> > > <filter-mapping> > <filter-name>struts2</filter-name> > <url-pattern>/*</url-pattern> > > <filter-name>Set Character Encoding</filter-name> > <url-pattern>/*</url-pattern> > </filter-mapping> > > Then I start tomcat,but it raise follows error when tomcat start,the errors > like follows; > info: XML validation disabled > log4j:WARN No appenders could be found for logger ( > org.springframework.web.context.ContextLoader). > log4j:WARN Please initialize the log4j system properly. > 2006-12-13 23:43:31 org.apache.catalina.core.StandardContext start > fatal: Error filterStart > 2006-12-13 23:43:31 org.apache.catalina.core.StandardContext start > fatal: Context [/exercise] startup failed due to previous errors > > I guess I must make a mistake in web.xml,but I don't know how to correctly > configure it,anyone could tell how to do it? > By the way,when tomcat start,it always say > log4j:WARN No appenders could be found for logger ( > org.springframework.web.context.ContextLoader). > log4j:WARN Please initialize the log4j system properly. > > why raise above warn message,how to correct it? > > Thanks in advance! > >
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]