您的位置:首页 > 编程语言 > Java开发

SpringMVC 过滤器 以及注解的一些应用

2015-03-30 17:02 232 查看
继承自 OncePerRequestFilter 接口。

获取用户的IP: request.getLocalAddr().toString();

获取用户Session request.getSession().getAttribute("adminUser")

ModelAndView view=new ModelAndView();

view.setViewName("admin/index");

view.addObject("error", "用户名或密码错误,请重试!"); 在前台可以直接取得 error 用EL表达式就可以 ${error}

@ModelAttribute("admin")Admin admin 其实有没有@ModelAttribute("admin")无所谓 在前台的 name 要和 admin的属性相对应

<input type="password" class="form-control" id="password" name="password" placeholder="密码">

href="list/校友会.html"

@RequestMapping(value = "/list/{type}.html", method = RequestMethod.GET)

@PathVariable("type")String type

jstl标签:<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<c:forEach var="topnews" varStatus="status" items="${allNewsList}" begin="0" end="0">

<a href="news.html?id=${topnews.id}" target="_blank">

</c:forEach>

<c:choose>
<c:when test="${newstype == 'allnews'}">
全部新闻
</c:when>
<c:when test="${newstype == '通知'}">
通知公告
</c:when>
<c:otherwise>
${newstype }
</c:otherwise>
</c:choose>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐