如何使用< c:out value = ...>标签库 [英] How to use <c:out value=...> taglib
本文介绍了如何使用< c:out value = ...>标签库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有A类:
package a;
public class A {
private int x = 9;
public int getX() {
return x;
}
}
和ajsp.jsp文件:
and the ajsp.jsp file:
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<jsp:useBean id = "a" class = "a.A" />
<c:out value = "${a.x}" />
</body>
</html>
当我运行它时,它给出一个错误:
when i run it, it gives an error :
- org.apache.jasper.JasperException:/ajsp.jsp(11,0)PWC6236:根据标签文件中的TLD或属性指令,属性值不接受任何表达式
如果我使用的是<jsp:getProperty property="x" name="a"/>
而不是<c:out value = "${a.x}" />
,则它非常完美.
那么,有什么问题呢?
谢谢你.
if instead of <c:out value = "${a.x}" />
i use <jsp:getProperty property="x" name="a"/>
it goes perfect.
So, what is the problem?
Thank advance.
推荐答案
您的taglib URI不正确,您使用的是旧的预表达式,JSP 2.0版以前的库的URI.
Your taglib URI is incorrect, you're using the URI of the old pre-expression, pre-JSP 2.0 library.
代替
http://java.sun.com/jstl/core
应该是
http://java.sun.com/jsp/jstl/core
http://java.sun.com/jsp/jstl/core
这篇关于如何使用< c:out value = ...>标签库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文