浏览 8868 次
锁定老帖子 主题:[提问]JSTL的奇怪问题?
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
---|---|
作者 | 正文 |
发表时间:2005-12-13
JSP内容如下: <%@ page contentType="text/html" %> <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %> <%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %> <% request.setAttribute("modle", "This is test modle"); %> ${modle} <c:url value="/test.jsp"/> <c:out value="${modle}"/><==这行有问题,去掉这行就正常. 报的异常是: org.apache.jasper.JasperException: /test.jsp(20,0) According to TLD or attribute directive in tag file, attribute value does not accept any expressions org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:39) org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:405) org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:146) org.apache.jasper.compiler.Validator$ValidateVisitor.checkXmlAttributes(Validator.java:955) org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:710) org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1441) org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2163) org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2213) org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2219) org.apache.jasper.compiler.Node$Root.accept(Node.java:456) org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2163) org.apache.jasper.compiler.Validator.validate(Validator.java:1489) org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:157) org.apache.jasper.compiler.Compiler.compile(Compiler.java:286) org.apache.jasper.compiler.Compiler.compile(Compiler.java:267) org.apache.jasper.compiler.Compiler.compile(Compiler.java:255) org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:293) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) 声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
返回顶楼 | |
发表时间:2005-12-13
c.tld中out属性没有打开EL支持,见
<name>out</name> <tag-class>org.apache.taglibs.standard.tag.rt.core.OutTag</tag-class> <body-content>JSP</body-content> <attribute> <description> Expression to be evaluated. </description> <name>value</name> <required>true</required> <rtexprvalue>true</rtexprvalue> </attribute> 里边的 <rtexprvalue>true</rtexprvalue> 你的应该是false 其他属性同。 |
|
返回顶楼 | |
发表时间:2005-12-13
找到原因了是JSTL1.0和1.1的uri不一样.
|
|
返回顶楼 | |
发表时间:2005-12-13
JSTL版本问题
JSP2.0已经包含EL,所以JSTL1.2不提供EL,而由容器提供 解决办法有两种: 1)使用老版本的JSTL1.0以及JSP1.2 2)升级到JSTL1.1及JSP2.0 |
|
返回顶楼 | |
发表时间:2005-12-13
resin-3.0.16
在它带的例子中${modle}可以的, 在我的应用中没有解析直接输出${modle}串,什么样的jar包会造成这样的影响?难道我的某一个jar使它的EL表达式失效了? |
|
返回顶楼 | |
发表时间:2005-12-13
如果你使用JSTL1.1以上的版本,要在你的JSP头部定义:
<%@ page isELIgnored ="false"%> 不过很奇怪的是,既然${}已经能输出了,你为什么还要使用恶心的c:out? |
|
返回顶楼 | |
发表时间:2005-12-14
downpour 写道 如果你使用JSTL1.1以上的版本,要在你的JSP头部定义:
<%@ page isELIgnored ="false"%> 不过很奇怪的是,既然${}已经能输出了,你为什么还要使用恶心的c:out? 用c:out是测试用的. 加上这个<%@ page isELIgnored ="false"%>就可以了, EL不是JSP2.0的specification吗? 为什么和JSTL还有联系,难道我把JSTL换成1.0就不需要这个了<%@ page isELIgnored ="false"%>吗? 能否解释一下,谢谢. |
|
返回顶楼 | |
发表时间:2005-12-20
Starting with JSP 2.0, EL expressions can directly be used in template text and in attribute values for any action element. A JSP application written for a prior version of the JSP specification, however, may use constructs that look like EL expressions and expect them to be used as literal strings instead of being evaluated.
To deal with this potential problem, the JSP 2.0 specification defines two ways to disable EL expression evaluation. First, EL expression evaluation is disabled by default for a web application with a deployment descriptor that is not Servlet 2.4 conformant (i.e., an application developed for a previous version of the Servlet and JSP specifications), and it's enabled by default for a web application with a Servlet 2.4 deployment descriptor. This guarantees that an old JSP application can be deployed in a JSP 2.0 container with full backwards compatibility, while a sensible default is provided for new applications. Second, the EL expression evaluation can be explicitly disabled in a JSP 2.0 application—for a single page with the elIgnored page attribute, or for a set of JSP pages with an <el-ignored> element in a JSP group: <web-app ...> ... <jsp-config> <jsp-property-group> <url-pattern>*.jsp</url-pattern> <el-ignored>true</el-ignored> </jsp-property-grop> </jsp-config> ... </web-app> The ability to disable EL evaluation in a JSP 2.0 application allows you to migrate an old application to the new JSP 2.0 features a few pages at a time, ensuring that the pages that have not yet been migrated behave as they did with JSP 1.2. If you define the EL evaluation mode with an <el-ignored> element in the deployment descriptor, you can override this setting with the elIgnored page attribute in individual pages. For instance, you can disable EL evaluation for all JSP pages with the deployment descriptor snippet shown here, and selectively enable it with the elIgnored attribute in each JSP page that's reviewed and migrated to JSP 2.0: <%@ page elIgnored="false" %> |
|
返回顶楼 | |