A path coding problems
com.itstaredu.servlet Package; Import javax.servlet.ServletException; Import the javax.servlet.http.HttpServlet; Import the javax.servlet.http.HttpServletRequest; Import javax.servlet.http.HttpServletResponse; Import java.io.IOException; / * * * use an absolute path * / project name / ...... * absolute path begins with / * when the dispatcher does not need to forward the project under the same name as a project * with the project name server will resolve not to add * browser parses do not add our own project name * base tag <base href = "http: // localhost: 8080 / javaweb07 /" /> behind the increase in the relative path * absolute path begins with / * relative path does not start with / * encoding issues ISO-8859- 1 * server re-re-encoding the decoded * request Add URIEncoding = "UTF-8" or not in line connector tab server.xml 65 * <p> * request.setCharacterEncoding("UTF-8"); * response.setContentType("text/html;charset=UTF-8"); * response.setHeader("content-Type","text/html;charset=UTF-8"); */ public class PathServlet extends HttpServlet { @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doGet(request, response); } @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.setCharacterEncoding("UTF-8"); response.setContentType("text/html;charset=UTF-8"); . response.getWriter () write ( "Three Kingdoms"); String name = request.getParameter("username0"); System.out.println(name); } }