急急急 初学者遇到表单提交乱码问题?
我是一个初学者,对如何新建过滤器,在web.xml如何链接不知道?请高手指教!
具体问题:
遇到表单提交乱码问题,在tomcat的目录中复制SetCharacterEncodingFilter.class文件到D:\jakarta-tomcat-5.0.28\webapps\box\WEB-INF\classes\ch2\util\filter目录下
可是myeclipse无法编译通过以下是web.xml中的内容,请指教问题出在哪里?
<servlet>
<description>This is the description of my J2EE component</description>
<display-name>This is the display name of my J2EE component</display-name>
<servlet-name>fristServlet</servlet-name>
<servlet-class>com.box.fristServlet</servlet-class>
</servlet>
<servlet>
<description>This is the description of my J2EE component</description>
<display-name>This is the display name of my J2EE component</display-name>
<servlet-name>IoFileServlet</servlet-name>
<servlet-class>com.box.IoFileServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>fristServlet</servlet-name>
<url-pattern>/servlet/fristServlet</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>IoFileServlet</servlet-name>
<url-pattern>/servlet/IoFileServlet</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<filter>
<filter-name>Set Character Encoding</filter-name>
<filter-class>classes.ch2.util.filters.SetCharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>GBK</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>Set Character Encoding</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
[解决办法]
[code=XML]<filter> <filter-name>Set Character Encoding </filter-name> <filter-class>classes.ch2.util.filters.SetCharacterEncodingFilter </filter-class> <init-param> <param-name>encoding </param-name> <param-value>GBK </param-value> </init-param> </filter> <filter-mapping> <filter-name>Set Character Encoding </filter-name> <url-pattern>/* </url-pattern> </filter-mapping>