controller:
@RequestMapping(value = "/auto", method = RequestMethod.GET)
public @ResponseBody
AvailabilityStatus getAvailability(@RequestParam String name,Locale locale, HttpSession httpSession) {
logger.info("Welcome auto! the client locale is " + locale.toString());
ResourceBundle myResources =
ResourceBundle.getBundle("messages", locale);
String aha = myResources.getString("label.lastname");
System.out.println( name );
httpSession.setAttribute("accountBean", this );
return AvailabilityStatus.notAvailable(aha);
}
jsp:
<c:if test="${sessionScope.accountBean111 != null}">
<p>aaa</p>
</c:if>
注意在jsp页面中不能有<%@ page session="false" %>
本文介绍了一个使用Spring MVC框架的示例,展示了如何在控制器中设置会话属性,并在JSP页面上检查这些属性是否存在。此外,还演示了如何通过国际化资源文件根据客户端的地区设置返回不同的消息。
406

被折叠的 条评论
为什么被折叠?



