第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

我寫(xiě)的過(guò)濾器為什么不起作用???求高手指點(diǎn),萬(wàn)分感謝

我寫(xiě)的過(guò)濾器為什么不起作用啊?求高手指點(diǎn),萬(wàn)分感謝

qq_莫非 2017-11-19 17:13:58
webcontent目錄下的jsp: <%@?page?language="java"?contentType="text/html;?charset=utf-8" ????pageEncoding="utf-8"%> <!DOCTYPE?html?PUBLIC?"-//W3C//DTD?HTML?4.01?Transitional//EN"?"http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta?http-equiv="Content-Type"?content="text/html;?charset=utf-8"> <title>Insert?title?here</title> </head> <body> <form?action="Servlet1"?method="post"> <table> <tr> <td>姓名:</td> <td><input?type="text"?name="name"></td> </tr> <tr> <td>ename:</td> <td><input?type="text"?name="ename"></td> </tr> </table> <button?class="submit">提交</button> </form> </body> </html> servlet包里面的Servlet1: package?servlet; import?java.io.IOException; import?java.io.PrintWriter; import?javax.servlet.ServletException; import?javax.servlet.annotation.WebServlet; import?javax.servlet.http.HttpServlet; import?javax.servlet.http.HttpServletRequest; import?javax.servlet.http.HttpServletResponse; import?javax.servlet.http.HttpSession; import?org.apache.catalina.Session; /** ?*?Servlet?implementation?class?Servlet1 ?*/ @WebServlet("/Servlet1") public?class?Servlet1?extends?HttpServlet?{ private?static?final?long?serialVersionUID?=?1L; ??????? ????/** ?????*?@see?HttpServlet#HttpServlet() ?????*/ ????public?Servlet1()?{ ????????super(); ????????//?TODO?Auto-generated?constructor?stub ????} /** ?*?@see?HttpServlet#doGet(HttpServletRequest?request,?HttpServletResponse?response) ?*/ protected?void?doGet(HttpServletRequest?request,?HttpServletResponse?response)?throws?ServletException,?IOException?{ //?TODO?Auto-generated?method?stub //response.setContentType("text/html;charset=utf-8"); // request.setCharacterEncoding("utf-8"); PrintWriter?out=response.getWriter(); String?info=request.getParameter("name"); String?ename=request.getParameter("ename"); out.println(info); out.println(ename); out.close(); } /** ?*?@see?HttpServlet#doPost(HttpServletRequest?request,?HttpServletResponse?response) ?*/ protected?void?doPost(HttpServletRequest?request,?HttpServletResponse?response)?throws?ServletException,?IOException?{ //?TODO?Auto-generated?method?stub doGet(request,?response); } } filter包里面的: package?filter; import?java.io.IOException; import?java.util.Enumeration; import?java.util.HashMap; import?java.util.Map; import?javax.servlet.Filter; import?javax.servlet.FilterChain; import?javax.servlet.FilterConfig; import?javax.servlet.ServletException; import?javax.servlet.ServletRequest; import?javax.servlet.ServletResponse; import?javax.servlet.annotation.WebFilter; /** ?*?Servlet?Filter?implementation?class?EncodingFilter ?*/ @WebFilter("/EncodingFilter") public?class?EncodingFilter?implements?Filter?{ ????private?String?encoding; /** ?*?@see?Filter#destroy() ?*/ public?void?destroy()?{ //?TODO?Auto-generated?method?stub System.out.println("end?do?the?encoding?filter"); encoding=null; } /** ?*?@see?Filter#doFilter(ServletRequest,?ServletResponse,?FilterChain) ?*/ public?void?doFilter(ServletRequest?request,?ServletResponse?response,?FilterChain?chain)?throws?IOException,?ServletException?{ //?TODO?Auto-generated?method?stub //?place?your?code?here //?pass?the?request?along?the?filter?chain System.out.println("before?encoding"+encoding+"filter"); request.setCharacterEncoding(encoding); response.setContentType("text/html;charset="+encoding); chain.doFilter(request,?response); System.out.println("after?encoding"+encoding+"filter"); } /** ?*?@see?Filter#init(FilterConfig) ?*/ public?void?init(FilterConfig?fConfig)?throws?ServletException?{ //?TODO?Auto-generated?method?stub System.out.println("begin?do?the?encoding?filter"); encoding=fConfig.getInitParameter("encoding"); } } web.xml的配置: <?xml?version="1.0"?encoding="UTF-8"?> <web-app?xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"?xmlns="http://xmlns.jcp.org/xml/ns/javaee"?xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee?http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"?id="WebApp_ID"?version="3.1"> ??<display-name>JavaEETask1</display-name> ??<filter> ?? <filter-name>setCE</filter-name> ?? <filter-class>filter.EncodingFilter</filter-class> ?? <init-param> ?? <param-name>encoding</param-name> ?? <param-value>utf-8</param-value> ?? </init-param> ??</filter> ??<filter-mapping> ?? <filter-name>setCE</filter-name> ?? <url-pattern>/JavaEETask1/Servlet1</url-pattern> ??</filter-mapping> </web-app>為什么過(guò)濾器不起作用?。??求指點(diǎn)
查看完整描述

3 回答

已采納
?
qq_20151109_0

TA貢獻(xiàn)22條經(jīng)驗(yàn) 獲得超11個(gè)贊

你的過(guò)濾器名字叫EncodingFilter,你配置的叫setCE,你說(shuō)能起作用不,還有你設(shè)置的匹配路徑也要注意

查看完整回答
反對(duì) 回復(fù) 2017-11-21
?
柒月君

TA貢獻(xiàn)2條經(jīng)驗(yàn) 獲得超0個(gè)贊


??????????<url-pattern>/JavaEETask1/Servlet1</url-pattern>


應(yīng)該是/servlet/Servlet1吧


好久不用了? 不好使還不報(bào)錯(cuò)? 應(yīng)該是配置問(wèn)題? 沒(méi)有掃到



查看完整回答
反對(duì) 回復(fù) 2017-11-23
?
元?dú)鉂M滿GO

TA貢獻(xiàn)92條經(jīng)驗(yàn) 獲得超16個(gè)贊

看看注解有沒(méi)有用對(duì)

查看完整回答
反對(duì) 回復(fù) 2017-11-20
  • 3 回答
  • 0 關(guān)注
  • 2954 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)