Servlet-1

mandarinduk·2021년 3월 17일
0

Servlet 특징

  • 동적 웹어플리케이션 컴포넌트
  • 확장자는 .java
  • 클라이언트의 요청에 동적으로 작동한다.
  • java thread를 이용해서 동작한다.(서버의 부하를 줄여준다)
  • MVC 패턴에서 controller 역할.

맵핑

  • 기존 경로
http://localhost:8080/hello(프로젝트명)/servlet/com.test.ex.hello
  • URL 맵핑 경로
http://localhost:8080/hello(프로젝트명)/he

맵핑 방법
1. web.xml에서 서블릿 맵핑

<servlet>
	<servlet-name>helloServlet</servlet-name>
    	<servlet-class>com.test.ex.Hello</servlet-class>
</servlet>
<servlet-mapping>
	<servlet-name>helloServlet</servlet-name>
    	<url-pattern>/he</url-pattern>
</servlet-mapping>
  1. 어노테이션 사용
@WebServlet("/He")
public class Hello extends HttpServlet {
  ...
}
profile
front-end 신입 개발자

0개의 댓글