合规国际互联网加速 OSASE为企业客户提供高速稳定SD-WAN国际加速解决方案。 广告
**1. 继承HttpServlet** ```java /** * @WebServlet注解指定请求地址 */ @WebServlet("/index") public class IndexServlet extends HttpServlet { @Override public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { this.doPost(request, response); } @Override public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.setAttribute("info", "Index"); request.getRequestDispatcher("WEB-INF/views/index.jsp").forward(request, response); } } ``` **2. `WEB-INF/views/index.jsp`页面** ```html <%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %> <!DOCTYPE html> <html> <head> <title>Index</title> </head> <body> <h1>${ info }</h1> </body> </html> ``` **3. 访问:http://localhost:8080/web/index** ![](https://img.kancloud.cn/4b/48/4b4813c1d1db7ab1a985aebe596c30c8_1507x303.png)