码迷,mamicode.com
首页 > 编程语言 > 详细

spring mvc 和 jstl

时间:2015-10-21 15:55:22      阅读:169      评论:0      收藏:0      [点我收藏+]

标签:

spring ,jstl 在maven配置文件的配置:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>3.1.2.RELEASE</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>taglibs</groupId>
<artifactId>standard</artifactId>
<version>1.1.2</version>
</dependency>

在springmvc 的 controller 中 我将一个 Note 对象(简单的包含一些属性,有get 和 set 方法)放入 ModelAndView 中,
在jsp端我想用el取值: ${note.name},但是它显示的还是 ${note.name}
在jsp中我用java代码获取就可以,但是jsp写java代码真的够不好看的。
谁知道是什么问题呢?
我的tomcat版本是7.0 dynamic web project 的版本是 2.3 ,我以为是 dynamic 版本的问题,maven 插件构造的版本是 2.3 我尝试修改文件,把版本修改为 3.0 但还是没用。
这是虾米原因呢,数据的准备是绝对没问题的,springmvc 也运行正确,springmvc的视图解析器也配置了:
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"
p:viewClass="org.springframework.web.servlet.view.JstlView"
p:prefix="/"
p:suffix=".jsp"/>

哦,对了,这是我的jsp代码:detail.jsp:

<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import="com.mapp.persistance.dto.Note"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%
request.setCharacterEncoding("utf-8");
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="../js/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="../kindeditor/plugins/code/code.js"></script>
<script type="text/javascript" src="../kindeditor/plugins/code/prettify.js"></script>
<link type="text/css" rel="stylesheet" href="../kindeditor/plugins/code/prettify.css" />
<script type="text/javascript">
$(document).ready(function(){
prettyPrint();
});
</script>
<title>Insert title here</title>
.......省略样式
</head>
<body>
<div id="head"></div>
<% Note note = (Note)request.getAttribute("note");%>
<div style="width:180px;height:30px;line-height:30px;margin-left:990px;">
<a href="delete.ctrl?id=<%out.print(note.getId());%>">删除</a> |
<a href="edit.ctrl?id=<%out.print(note.getId());%>">编辑</a> |
<a href="noteList.ctrl">返回列表</a>
</div>
<div id="main-body"
style="padding: 20px 5px;border: 1px solid #ededed; width: 1000px; margin: auto;">
<div id="title"
style="border-bottom: 1px solid #d1d1d1; font-size: 18px; text-align: center; font-family: ‘微软雅黑‘; font-weight: 700">
<%
out.print(note.getTitle());%>
</div>
<div id="info">perhaps_love
发表于<%out.print(note.getGmtCreate()); %>${note.id}</div>
<div id="content"><%out.print(note.getContent()); %></div></div>
</body>
</html>

spring mvc 和 jstl

标签:

原文地址:http://www.cnblogs.com/zhujiabin/p/4897883.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!