JSP served out as plain/text with source code
I have a JSP:
Code:
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<html>
<head>
<title>wtf</title>
</head>
<body>
<h2>Hello World!</h2>
<c:set var="membersUrl">
<c:url value="members" />
</c:set>
<a href="${membersUrl}">Members</a>
</body>
</html>
If I remove the DispatcherServlet (and, thus, the view resolver), it renders correctly. However, if I use the view resolver, I get:
Code:
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<html>
<head>
<title>wtf</title>
</head>
<body>
<h2>Hello World!</h2>
<c:set var="membersUrl">
<c:url value="members" />
</c:set>
<a href="${membersUrl}">Members</a>
</body>
</html>
The content type is set to plain/text and, even more oddly, the title of the page is "wtf" (indicating that the browser somehow read the title of the page).
For reference, here's my serlvet configuration:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd"
xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc">
<context:component-scan base-package="com.googlecode.ticktokk.mvc" />
<mvc:annotation-driven />
<mvc:default-servlet-handler />
<mvc:view-controller path="/login" view-name="login/index" />
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
</bean>
</beans>
...and here's my web.xml:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<web-app 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>TickTokk</display-name>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/applicationContext-*.xml</param-value>
</context-param>
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<servlet>
<servlet-name>ticktokk</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>ticktokk</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>