1、Webcontent的body中创建一个链接跳转到ServletDemo1;
2、ServletDemo1负责验证结果response.getWriter().write(“中国”);
3、CharacterEncodingFilter类中用Filter过滤器实现解决中午乱码问题
4、<filter>
<filter-name>CharacterEncodingFilter</filter-name>
<filter-class>cn.itcast.web.Filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>charset</param-name>
<param-value>UTF-8</param-value>
</init-param>
</filter>
<filter-mapping>
<servlet-name>CharacterEncodingFilter</servlet-name>
运行时这行出错,出错的原因求帮忙分析下
<url-pattern>/*</url-pattern>
</filter-mapping>
<servlet>
<description></description>
<display-name>ServletDemo1</display-name>
<servlet-name>ServletDemo1</servlet-name>
<servlet-class>cn.itcast.web.servlet.ServletDemo1</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ServletDemo1</servlet-name>
<url-pattern>/ServletDemo1</url-pattern>
</servlet-mapping>
5、提示出错:
Description Resource Path Location Type
cvc-complex-type.2.4.a: Invalid content was found starting with element “”servlet-name””.
One of “”{“http://java.sun.com/xml/ns/javaee”:filter-name}”” is expected.
2、ServletDemo1负责验证结果response.getWriter().write(“中国”);
3、CharacterEncodingFilter类中用Filter过滤器实现解决中午乱码问题
4、<filter>
<filter-name>CharacterEncodingFilter</filter-name>
<filter-class>cn.itcast.web.Filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>charset</param-name>
<param-value>UTF-8</param-value>
</init-param>
</filter>
<filter-mapping>
<servlet-name>CharacterEncodingFilter</servlet-name>
运行时这行出错,出错的原因求帮忙分析下
<url-pattern>/*</url-pattern>
</filter-mapping>
<servlet>
<description></description>
<display-name>ServletDemo1</display-name>
<servlet-name>ServletDemo1</servlet-name>
<servlet-class>cn.itcast.web.servlet.ServletDemo1</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ServletDemo1</servlet-name>
<url-pattern>/ServletDemo1</url-pattern>
</servlet-mapping>
5、提示出错:
Description Resource Path Location Type
cvc-complex-type.2.4.a: Invalid content was found starting with element “”servlet-name””.
One of “”{“http://java.sun.com/xml/ns/javaee”:filter-name}”” is expected.
解决方案:50分
你把那个charset 改成encoding 试试
<filter> <filter-name>encodingFilter</filter-name> <filter-class> org.springframework.web.filter.CharacterEncodingFilter </filter-class> <init-param> <param-name>encoding</param-name> <param-value>UTF-8</param-value> </init-param> <init-param> <param-name>forceEncoding</param-name> <param-value>true</param-value> </init-param> </filter> <filter-mapping> <filter-name>encodingFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>