Udemy Course Spring Framework 51-Servlet

ZONGRU Li
3 min readApr 2, 2019

--

What Is Servlet?

Servlet包含HTTP request與HTTP response

執行專案Maven Builder Goal:tomcat7:run

執行正常

進到http://localhost:8090/

按下F12再按NetWork並F5重整可見到

request所取得的狀態資訊

HTTP response內容如下:

整體運行方式:

Browser sends Http Request to Web Server

Code in Web Server =>Input:HttpRequest ,Output:HttpResponse

Web Server response with Http Response

而LoginServlet.java內定義的@WebServlet來自javaEE6的套件

指定了以下網址的request與response行為

跟web.xml轉向是一樣的(根據web.xml定義localhost:8090會導到/login.do這個Servlet內)

而瀏覽器發動的是Get Method,所以對應的LoginServlet.java內要定義

doGet這個方法

--

--

ZONGRU Li
ZONGRU Li

Written by ZONGRU Li

2022/11/17 開源部分個人筆記給LINE "Java程式語言討論區"社群,希望能對社群的技術學習做一點點貢獻.(掩面....記得退訂閱!

No responses yet