JSP | Controller Parameter get 받기
페이지 정보
작성자 굿스웹 작성일20-02-12 10:16 조회550회 댓글0건관련링크
본문
[Java Resources/src/main/jsp/HomeController]
@Controller
public class HomeController {
private static final Logger logger = LoggerFactory.getLogger(HomeController.class); //실행 로그 출력
@RequestMapping(value = "/", method = RequestMethod.GET)
public String home(Locale locale, Model model) {
logger.info("Welcome home! The client locale is {}.", locale);
Date date = new Date();
DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale);
String formattedDate = dateFormat.format(date);
model.addAttribute("serverTime", formattedDate );
return "home";
}
@GetMapping("/page/{restaurantId}")
public String getSurvey(@PathVariable("restaurantId") String restaurant, Model model) {
logger.info("Welcome home! The client locale is {}.", restaurant);
model.addAttribute("serverTime", restaurant );
return "home";
}
}
[src/WEB-INF/home]
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<html>
<head>
<title>Home</title>
</head>
<body>
<P> 내용 ${serverTime}. </P>
</body>
</html>
[출력]
http://127.0.0.1:8080/page/2123213
<P> 내용 2123213. </P>
@Controller
public class HomeController {
private static final Logger logger = LoggerFactory.getLogger(HomeController.class); //실행 로그 출력
@RequestMapping(value = "/", method = RequestMethod.GET)
public String home(Locale locale, Model model) {
logger.info("Welcome home! The client locale is {}.", locale);
Date date = new Date();
DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale);
String formattedDate = dateFormat.format(date);
model.addAttribute("serverTime", formattedDate );
return "home";
}
@GetMapping("/page/{restaurantId}")
public String getSurvey(@PathVariable("restaurantId") String restaurant, Model model) {
logger.info("Welcome home! The client locale is {}.", restaurant);
model.addAttribute("serverTime", restaurant );
return "home";
}
}
[src/WEB-INF/home]
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<html>
<head>
<title>Home</title>
</head>
<body>
<P> 내용 ${serverTime}. </P>
</body>
</html>
[출력]
http://127.0.0.1:8080/page/2123213
<P> 내용 2123213. </P>
[주소복사] https://www.goodsweb.kr/?u=D41ZdBG5
SNS 알리기
핀터레스트
텔레그램로
블로그로
페이스북
트위터
카카오스토리
카톡 공유
관련 블로그
로딩중