【问题标题】:Jetty7 standalone + jstl/jsp + spring 3 = el/spring tags not workingJetty7 独立 + jstl/jsp + spring 3 = el/spring 标签不工作
【发布时间】:2012-03-14 18:08:09
【问题描述】:

我在使用 Jetty7 独立版和使用 jsp/jstl/el 的 Spring Web 应用程序时遇到了一些问题。 虽然使用 maven jetty-plugin 一切正常,但一旦我切换到独立的 Jetty,所有 EL 消息,例如。 ${foobar} 和 spring 标记都被忽略了。

我的示例 JSP

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring" %>
<spring:message var="document_title" code="navigation.activity" />
<spring:message var="header_title" text="" code="navigation.activity" />
hello ${hello}

通过spring MVC控制器加载

@RequestMapping(value = "")
public String test(Model model) throws IOException {
    model.addAttribute("hello", "world");

    return "html/example";
}

web.xml:

<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="
    http://java.sun.com/xml/ns/javaee
    http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID"
version="2.5">
 ...

尝试使用和不使用以下依赖项:

    <dependency>
        <groupId>taglibs</groupId>
        <artifactId>fmt</artifactId>
        <version>1.1.2</version>
        <scope>runtime</scope>
        <type>tld</type>
    </dependency>

    <dependency>
        <groupId>taglibs</groupId>
        <artifactId>standard</artifactId>
        <version>1.1.2</version>
        <scope>runtime</scope>
    </dependency>

    <dependency>
        <groupId>taglibs</groupId>
        <artifactId>c</artifactId>
        <version>1.1.2</version>
        <scope>runtime</scope>
        <type>tld</type>
    </dependency>

    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>jstl</artifactId>
        <version>1.2</version>
        <scope>runtime</scope>
    </dependency>

我什至尝试通过 &lt;%@ page isELIgnored="false" %&gt; 在 JSP 中启用 EL,但随后出现如下异常:

An error occurred at line: 21 in the jsp file: /WEB-INF/template/html/example.jsp
Generated servlet error:
/tmp/jetty-0.0.0.0-8080-test.war-_-any-/jsp/org/apache/jsp/WEB_002dINF/template/html/example_jsp.java:268: cannot find symbol
symbol  : method proprietaryEvaluate(java.lang.String,java.lang.Class<java.lang.String>,javax.servlet.jsp.PageContext,<nulltype>,boolean)
location: class org.apache.jasper.runtime.PageContextImpl
      out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate("${hello}", java.lang.String.class, (PageContext)_jspx_page_context, null, false));

我浏览了大量网页、网络问题,但仍无法解决此问题。 希望任何人都能够帮助我。提前致谢!

【问题讨论】:

    标签: spring jsp jstl jetty el


    【解决方案1】:

    不确定是什么解决了我的问题,但我从 pom 中删除了所有 jsp/jstl 依赖项并将 web.xml 设置为 3.0。

    <web-app
        xmlns="http://java.sun.com/xml/ns/javaee" 
        xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
        id="Your_Webapp_ID" version="3.0">
    

    突然间它开始工作了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-12-12
      • 1970-01-01
      • 2011-10-06
      • 2013-11-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多