디지털 컨버전스/Spring
[Spring Framework] 서버 연결
gimyeondong
2020. 5. 27. 17:35
서버 설정
Servers 생성 확인
web-inf 폴더는 내부접근만 가능 (포워드 가능 리다이렉트 불가)
https://127.0.0.1:8085/controller/
서버 가동
http://localhost:8085/controller/
@RequestMapping
@Controller
@component
get 방식으로만 받기
@RequestMapping(value="/", method=RequestMethod.GET)
public String home() {
return "home";
}
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ page session="false"%>
<html>
<head>
<title>Home</title>
</head>
<body>
<form action="page1" method="get">
<input type=submit>
</form>
</body>
</html>
클라이언트 -> 서버 ->디스패쳐 -> 리퀘스트맵핑
post 방식만 받도록 설정해 놓으면
@Controller
public class HomeController {
@RequestMapping("/")
public String home() {
return "home";
}
@RequestMapping(value="/page1", method=RequestMethod.POST)
public String toPage1() {
return "page1";
}
}