【问题标题】:Spring and JSP EL not being processed未处理 Spring 和 JSP EL
【发布时间】:2011-11-01 19:46:19
【问题描述】:

我们正在运行 Tomcat 6.0 和 Spring 3.0.5,由于某种原因,我们无法让 jsps 评估 ${blah}。如果重要的话,这是一个包含许多单独模块的 Maven 项目,Eclipse Helios。

这是我的 web.xml 的片段

<web-app id="WebApp_ID" version="2.5" 
xmlns="http://java.sun.com/xml/ns/javaee" 
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_2_5.xsd">
<display-name>xc.rio</display-name>...

不是这个(),因为当我把它放在我的jsp中时,页面被呈现为仅文本含义

<%@ page isELIgnored="false" %>
<HTML>
...${blah}...

${2+2} 不被评估。我也在tomcat 7上试过这个。=-(

更新: 我已经完成了一个独立的 spring 和 nonspring 应用程序和 EL 工作。我以为它与 viewResolver 有关,但我猜也不是。

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:util="http://www.springframework.org/schema/util"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:camel="http://camel.apache.org/schema/spring"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
    http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
    http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
    http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">

    <mvc:annotation-driven />
    <bean id="handlerMapping" class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"> 
        <property name="detectHandlersInAncestorContexts" value="true" /> 
    </bean> 

    <mvc:default-servlet-handler/>

    <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
      <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
      <property name="suffix" value=".jsp"/>
    </bean>

</beans>

【问题讨论】:

  • 尝试使用“${2+2}”的简单页面。如果它呈现为 4,则问题不在 Tomcat 中。
  • 如果你用${2+2}部署一个简单的jsp webapp(没有spring),这会呈现为4?
  • 如果你使用 JSTL &lt;c:out value="${2+2}" /&gt; 会怎样?如果您从项目中删除所有 Spring 噪音(或创建一个没有任何 Maven 和 Spring 影响的全新项目)怎么办?

标签: jsp spring-mvc


【解决方案1】:

尝试删除导致 spring 将页面作为静态资源提供的&lt;mvc:default-servlet-handler/&gt;

【讨论】:

  • 做到了,但并非没有与我的 web.xml 中的 /* 有关的后果。
猜你喜欢
  • 1970-01-01
  • 2012-01-07
  • 2015-05-10
  • 2013-04-20
  • 2023-03-28
  • 1970-01-01
  • 1970-01-01
  • 2013-08-04
  • 1970-01-01
相关资源
最近更新 更多