JavaWeb15.1【response:HTTP之響應訊息】
阿新 • • 發佈:2021-07-01
1 <%-- 2 Created by IntelliJ IDEA. 3 User: yubaby 4 Date: 2021/7/1 5 Time: 10:12 6 To change this template use File | Settings | File Templates. 7 --%> 8 <%@ page contentType="text/html;charset=UTF-8" language="java" %> 9 <html> 10 <head> 11 <title>$Title$</title> 12 </head> 13 <body> 14 hello response 15 </body> 16 </html>
1 package com.haifei.servlet; 2 3 import javax.servlet.ServletException; 4 import javax.servlet.annotation.WebServlet; 5 import javax.servlet.http.HttpServlet; 6 import javax.servlet.http.HttpServletRequest;7 import javax.servlet.http.HttpServletResponse; 8 import java.io.IOException; 9 10 @WebServlet("/servletDemo1") 11 public class ServletDemo1 extends HttpServlet { 12 protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 13 14 }15 16 17 /*protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 18 }*/ 19 //http://localhost:8080/day15/servletDemo1 20 //-->報錯 405狀態碼 21 22 /*protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 23 int i = 3/0; 24 }*/ 25 //http://localhost:8080/day15/servletDemo1 26 //-->報錯 500狀態碼 27 28 29 @Override 30 protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { 31 32 } 33 }