@RequestMapping(value = "/", method = RequestMethod.GET)
public String homePage(Locale locale, Model model) {
Date date = new Date();
DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale);
String formattedDate = dateFormat.format(date);
model.addAttribute("serverTime", formattedDate);
return "/home";
}
컨트롤 단에서
model.addAttribute 로 serverTime를 설정하고
이를 jsp에서
<P> The time on the server is ${serverTime}. </P>
이런식으로 사용은 아주 깔끔하고 좋습니다
하지만 저 serverTime 라는 모델 어트리뷰트를
jsp페이지의
<% %> 스크립트 릿 안에다 사용해보고 싶은데
어찌해야 할지를 모르겠네요...
제가 책에서 놓쳤을수도 있지만
스크립트릿 안에다가
<%= ${serverTime } %>
<%= serverTime %>
모 이런것들도 아닌거 같아서요
컨트롤 모델에 설정한 값을 스크립트릿 안에서 사용하는 법을 알고 싶습니다