2-15 서블릿, jsp(3)

서현우·2022년 5월 23일
0

복습

목록 보기
12/34
post-thumbnail

URL패턴
@WebServlet으로 서블릿을 URL에 맵핑할 때 사용.
우선순위 높은데서 낮은데 순으로
1.exact mapping : /login/hello.do
2.path mapping : /login/
3.extension mapping :
.do
4.default mapping : /

Spring은 DispatcherServlet이 자체적으로 관리하는 URL패턴으로 유사하게 처리

EL(Expression Language)
<%= 값 %> => ${값}

EL

<%@ 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은 출력 시 비어있음.
null+1 = ${null+1} <br> //"", bull은 사칙연산 시 0으로 계산.
null+null = ${null+null} <br>
"" + null = ${""+null} <br>   
""-1 = ${""-1} <br> 
empty null=${empty null} <br> //${empty ...} 비어있으면 true
empty list=${empty list} <br>
null==0 = ${null==0} <br> //null은 0으로 계산하지만 0은 아님.
null eq 0 = ${null eq 0} <br> //eq(==)
name == "남궁성"=${name=="남궁성"} <br>
name != "남궁성"=${name!="남궁성"} <br>
name eq "남궁성"=${name eq "남궁성"} <br>   
name ne "남궁성"=${name ne "남궁성"} <br> //ne는 not eq 
name.equals("남궁성")=${name.equals("남궁성")} <br>   
</body>
</html>
profile
안녕하세요!!

0개의 댓글