0

Long time reader first time typer. I've been trying to setup a simple spring3 and hibernate4 maven driven webapp on tomcat7. I had all the annotations working great my pages were loading and the controller logic was working well.

For some reason my jsp pages starting showing up in my web browser as raw code. It turns out they do that if I put the <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> first in the jsp before the <html> tag.

Also the jsps are not showing up as compiled code in the wtp work dir. I'm doing this in eclipse. Yes, I tried mvn packaging it and dropping it on a real tomcat 7 instance. Same thing.

The code is actually here

https://github.com/rbeltran/spring-mvc-petclinic

I'm trying to setup a simple spring-mvc petclinic to performance test it against the same thing in grails. I'm just enabling adding/viewing of Owners for now.

If anyone has any ideas why I'm getting raw jsp/html code and why the models are not resolving when page displays properly please let me know. Also it should be noted that the content-type is coming through as plain text when the raw jsp code comes through and text/html when the pages show up looking good.

Here is my web.xml

<?xml version="1.0" encoding="UTF-8"?>
<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_3_0.xsd" id="WebApp_ID" version="3.0">
  <display-name>spring-mvc-petclinic</display-name>
  <welcome-file-list>
    <welcome-file>/views/hello.jsp</welcome-file>
  </welcome-file-list>

    <servlet>
        <servlet-name>appServlet</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>appServlet</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>

    <context-param>
        <param-name>log4jConfigLocation</param-name>
        <param-value>/WEB-INF/log4j.properties</param-value>
    </context-param>    
    <listener>
        <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
    </listener>

</web-app>

my appServlet-servlet.xml is too big to paste here I think

0

1 Answer 1

2

Ok I went through my config xml files line by line with restarts and it turns out a line in my web.xml was the issue. I want to punch someone at vmware. I changed this:

<servlet-mapping>
    <servlet-name>appServlet</servlet-name>
    <url-pattern>/*</url-pattern>
</servlet-mapping>

to this :

<servlet-mapping>
    <servlet-name>appServlet</servlet-name>
    <url-pattern>/</url-pattern>
</servlet-mapping>

Now my jsps display perfectly and my model variables show up.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.