Announcement Announcement Module
Collapse
No announcement yet.
spring 3.2 + ContentNegotiationManagerFactoryBean don't parse JSP Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • spring 3.2 + ContentNegotiationManagerFactoryBean don't parse JSP

    Hello.
    I have the dispatcher with config:
    Code:
    <mvc:default-servlet-handler/>
    
        <context:annotation-config/>
        <context:component-scan base-package="ru.ulmart.web.admin.controller"/>
    
        <bean id="contentNegotiationManager" class="org.springframework.web.accept.ContentNegotiationManagerFactoryBean">
            <property name="favorPathExtension" value="false" />
            <property name="favorParameter" value="false" />
            <property name="ignoreAcceptHeader" value="false" />
            <property name="mediaTypes">
                <value>
                    json=application/json
                    html=text/html
                </value>
            </property>
        </bean>
        <mvc:annotation-driven content-negotiation-manager="contentNegotiationManager">
            <mvc:message-converters>
                <bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
                    <property name="objectMapper" ref="jacksonObjectMapper"/>
                </bean>
            </mvc:message-converters>
        </mvc:annotation-driven>
    
        <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
            <property name="viewClass" value="org.springframework.web.servlet.view.JstlView" />
            <property name="prefix">
                <value>/WEB-INF/restpages/</value>
            </property>
            <property name="suffix">
                <value>.jsp</value>
            </property>
        </bean>
    The JSP Page:
    Code:
    <%@ page contentType="text/html;charset=UTF-8" language="java" %>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
    <html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
        <title>Просмотр версии <c:out value="${versionNumber}"/> для объекта <c:out value="${objectName}"/></title>
    </head>
    <body>
    <c:out value="${objectData}"/>
    </body>
    </html>
    and the controller:
    Code:
    @Controller
    @RequestMapping(value = "/rest")
    public class RESTController {
    
        @RequestMapping(value = "/version/view/{versionId}", method = RequestMethod.GET, produces = MediaType.TEXT_HTML_VALUE)
        public String getViewVersionAsHTML(@PathVariable("versionId") String versionId,
                                           Model model,
                                           HttpServletRequest request,
                                           HttpServletResponse response) {
            String resultHTML = "versionview";
            return resultHTML;
        }
    }
    But when i try to open: http://localhost:8080/web-admin/rest/version/view/8 i get the page as it is with put parsing any jsp tags:
    Code:
    <%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <html> <head>     <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>     <title>абаОбаМаОбб аВаЕббаИаИ <c:out value="${versionNumber}"/> аДаЛб аОаБбаЕаКбаА <c:out value="${objectName}"/></title> </head> <body> <c:out value="${objectData}"/> </body> </html>

    What i do wrong?

  • #2
    Check out this post: http://forum.springsource.org/showth...-Spring-MVC3-2

    Comment


    • #3
      If i try the config from this thread i get always 404 exception while try to get json from url: http://localhost:8080/web-admin/rest/version/view/8 or http://localhost:8080/web-admin/rest...on/view/8.html and the same with json

      Comment


      • #4
        The problem was:
        Code:
        <servlet-mapping>
                <servlet-name>restServlet</servlet-name>
                <url-pattern>/*</url-pattern>
            </servlet-mapping>
        Replaced by:
        Code:
        <servlet-mapping>
                <servlet-name>restServlet</servlet-name>
                <url-pattern>/</url-pattern>
            </servlet-mapping>

        Comment

        Working...
        X