Burninghering's Blog
article thumbnail

1. URL 패턴

@WebServlet으로 서블릿을 URL에 맵핑할 때 사용 

- loadOnStartup이란?

서블릿은 lazy-init을 쓰는데

loadOnStartup 을 쓰면 미리 초기화가 가능하다.

=1은 우선순위를 적어준 것이다.

 

1. exact mapping 

정확히 일치/매핑하는 것, 우선 순위가 가장 높다

 

2. path mapping

경로 매핑, /login/*으로 된 것에 모두 매핑이 되는 것이다

 

3. extension mapping

확장자 매핑. *.do라고 URL매핑된 것을 연결한다

 

4. default mapping

모든 주소에 매핑 되는 것. 우선 순위가 가장 낮다

 

Sevlet Context안에

children map

servlet mappings 

두 가지의 Map이 있다.

 

요청이 오면, 요청과 일치하는 servlet mappings을 먼저 확인한다.

요청과 일치하는 것이 있는지 확인한다.

/hello를 매핑하면 HelloServlet이 처리한다.

(children map으로 가서 주소를 확인한다.)

 

스프링은 서블릿이나 jsp를 사용하지 않는다.

그래서 모든 요청을 default로 연결되어있는 디스패처서블릿이 받는다. 

 

1.1. 스프링과 서블릿의 차이 

서블릿을 등록하면,

두 개의 테이블에 저장된다.

스프링은 디스패처 서블릿 안에 두 개의 테이블처럼 유사하게 되어있다. 

 

2. JSP에서 사용하는 EL(Expression Language)

<%=값%>를 ${값}

으로 쓰게 해준다.

간단하고 편리하다.

 

<java />
<%@ page contentType="text/html;charset=utf-8"%> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> <%@ page import="com.fastcampus.ch2.*" %> <% Person person = new Person(); request.setAttribute("person", person); request.setAttribute("name", "남궁성"); request.setAttribute("list", new java.util.ArrayList()); %> <html> <head> <title>EL</title> </head> <body> person.getCar().getColor()=<%=person.getCar().getColor()%> <br> person.getCar().getColor()=${person.getCar().getColor()} <br> person.getCar().getColor()=${person.car.color} <br> name=<%=request.getAttribute("name")%> <br> name=${requestScope.name} <br> name=${name} <br> id=<%=request.getParameter("id")%> <br> id=${pageContext.request.getParameter("id")} <br> id=${param.id} <br> "1"+1 = ${"1"+1} <br> "1"+="1" = ${"1"+="1"} <br> "2">1 = ${"2">1} <br> null = ${null}<br> null+1 = ${null+1} <br> null+null = ${null+null} <br> "" + null = ${""+null} <br> ""-1 = ${""-1} <br> empty null=${empty null} <br> empty list=${empty list} <br> null==0 = ${null==0} <br> null eq 0 = ${null eq 0} <br> name == "남궁성"=${name=="남궁성"} <br> name != "남궁성"=${name!="남궁성"} <br> name eq "남궁성"=${name eq "남궁성"} <br> name ne "남궁성"=${name ne "남궁성"} <br> name.equals("남궁성")=${name.equals("남궁성")} <br> </body> </html>


본 포스팅은 패스트캠퍼스 환급 챌린지 참여를 위해 작성되었습니다.

http://bit.ly/3Y34pE0

 

패스트캠퍼스 [직장인 실무교육]

프로그래밍, 영상편집, UX/UI, 마케팅, 데이터 분석, 엑셀강의, The RED, 국비지원, 기업교육, 서비스 제공.

fastcampus.co.kr

 

profile

Burninghering's Blog

@개발자 김혜린

안녕하세요! 반갑습니다.