ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
![](https://box.kancloud.cn/867033bc0781966623dc9ff77effe4bb_516x290.png) ![](https://box.kancloud.cn/9900a2d2f4dcbc11732148a3f8081daf_511x347.png) ServletTest3.java ~~~ package zyw.servlet; 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 java.io.IOException; @WebServlet(name = "ServletTest3",urlPatterns = "/test3") public class ServletTest3 extends HttpServlet { protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { } protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String encoding=this.getServletContext().getInitParameter("encoding"); System.out.println("encoding="+encoding); } } ~~~ web.xml ~~~ <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd" version="4.0"> <context-param> <param-name>encoding</param-name> <param-value>utf-8</param-value> </context-param> <servlet> <servlet-name>HelloServlet</servlet-name> <servlet-class>zyw.servlet.HelloServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>HelloServlet</servlet-name> <url-pattern>/hi</url-pattern> </servlet-mapping> </web-app> ~~~ ![](https://box.kancloud.cn/efe2fd0dfb7a002a36313ffbbc174872_160x73.png)