我使用Spring创建了一个cloundfoundry应用程序。但是,我的jsp文件被呈现为纯文本(就像Tomcat没有执行源代码一样)。浏览器在请求特定URL时显示源。
文件结构
webapps
-jsp
-javascripts
-css
-WEB-INF
的web.xml:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:META-INF/spring/applicationContext*.xml</param-value>
</context-param>
<welcome-file-list>
<welcome-file>/jsp/index.jsp</welcome-file>
</welcome-file-list>
<!-- Creates the Spring Container shared by all Servlets and Filters -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- Handles Spring requests -->
<servlet>
<servlet-name>Honesty</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>WEB-INF/spring/webmvc-config.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Honesty</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
spring config:
<!-- Turns on support for mapping requests to Spring MVC @Controller methods
Also registers default Formatters and Validators for use across all @Controllers -->
<mvc:annotation-driven/>
<context:annotation-config />
<mvc:default-servlet-handler/>
感谢您提供的任何见解。它好像Tomcat没有在JSP源显示的情况下提供请求,而不是JSP呈现的页面。
响应标头将nginx显示为服务器:
Connection:keep-alive
Date:Mon, 30 Jul 2012 03:58:16 GMT
ETag:W/"611-1343620259000"
Keep-Alive:timeout=20
Server:nginx
答案 0 :(得分:1)
您使用的是Spring MVC吗?我想你把JSP放在一些可以访问的资源目录中。希望看到您的弹簧配置文件和项目结构。
答案 1 :(得分:1)
问题是我的servlet映射“/ *”。切换到“/”,现在一切都按预期工作。