标签取值问题,在线等。

夕阳下的高山 2012-08-13 10:22:54
<%@ page language="java" import="java.util.*,com.gs.entity.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>My JSP 'index.jsp' starting page</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->

</head>

<body>

<%
//User u = new User();
// u.setName("gs");
//u.setAge(15);
//request.setAttribute("user1",u);

request.setAttribute("abc","123");
%>


<c:out value="${abc}"></c:out>
</body>
</html>

页面如上,为什么说value属性无效?运行后报异常。
...全文
329 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
夕阳下的高山 2012-08-13
  • 打赏
  • 举报
回复
你说的对啊,我引错包了。
宏Lee 2012-08-13
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 的回复:]

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
应该是这个
[/Quote]
然后其他的照着你以前的写,肯定没问题了,在2楼的时候我没仔细看,所以没得出你想要的结果
宏Lee 2012-08-13
  • 打赏
  • 举报
回复
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
应该是这个
breakingdancer 2012-08-13
  • 打赏
  • 举报
回复
可能是因为使用了JSP2.0版本, 同时又没有使用JSTL core库的备用版本(RT库)
夕阳下的高山 2012-08-13
  • 打赏
  • 举报
回复
不对,我说用${ }取值为什么会报错,你那样写肯定是显示abc,取不出来值。
宏Lee 2012-08-13
  • 打赏
  • 举报
回复
这个是当前页面,不是请求以后跳转的页面,应该是:
<%
// request.setAttribute("abc","123");
pageContext.setAttribute("abc","123");
%>


<c:out value="abc" ></c:out>
夕阳下的高山 2012-08-13
  • 打赏
  • 举报
回复
为什么abc属性取不出来值呢?

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧