我使用 Spring 创建了一个 cloundfoundry 应用程序。但是,我的 jsp 文件被呈现为纯文本(好像 Tomcat 没有执行源代码)。浏览器在请求特定 URL 时会显示来源。
文件结构
webapps
-jsp
-javascripts
-css
-WEB-INF
网页.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>
弹簧配置:
<!-- 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