mercredi 25 mars 2015

Spring MVC couldn't render webpage

I have a Jquery Datatable. I also have an edit button to edit an entry in the table. On click of the button, I am making a server call to render update page.


Web.xml



<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>

<web-app xmlns="http://ift.tt/nSRXKP" xmlns:xsi="http://ift.tt/ra1lAU" version="2.5" xsi:schemaLocation="http://ift.tt/nSRXKP http://ift.tt/LU8AHS">
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:META-INF/spring/applicationContext*.xml, WEB-INF/spring/webmvc-config.xml</param-value>
</context-param>
<!-- Enable escaping of form submission contents -->
<context-param>
<param-name>defaultHtmlEscape</param-name>
<param-value>true</param-value>
</context-param>
<filter>
<filter-name>CharacterEncodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter>
<filter-name>HttpMethodFilter</filter-name>
<filter-class>org.springframework.web.filter.HiddenHttpMethodFilter</filter-class>
</filter>
<filter>
<filter-name>Spring OpenEntityManagerInViewFilter</filter-name>
<filter-class>org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>CharacterEncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

<filter-mapping>
<filter-name>HttpMethodFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

<filter-mapping>
<filter-name>Spring OpenEntityManagerInViewFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- Handles Spring requests -->
<servlet>
<servlet-name>billing</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value></param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>

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


webmvc-config.xml



<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<beans xmlns="http://ift.tt/GArMu6" xmlns:context="http://ift.tt/GArMu7" xmlns:mvc="http://ift.tt/1bHqwjR" xmlns:p="http://ift.tt/1jdM0fE" xmlns:xsi="http://ift.tt/ra1lAU" xsi:schemaLocation="http://ift.tt/GArMu6 http://ift.tt/1cMYE2s http://ift.tt/GArMu7 http://ift.tt/1dfrlFf http://ift.tt/1bHqwjR http://ift.tt/1cKeJ91">
<!-- The controllers are autodetected POJOs labeled with the @Controller annotation. -->
<context:component-scan base-package="com.pkg.GDS.web" use-default-filters="true">
<context:include-filter expression="org.springframework.stereotype.Controller" type="annotation"/>
</context:component-scan>

<!-- For Spring MVC -->
<!-- Enable Spring MVC annotation at type & method level -->
<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"/>

<!--
Tells Spring which input methods we support (it will be useful when we send objects to the server via REST).
-->
<bean
class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
<property name="messageConverters">
<list>
<bean id="mappingJacksonHttpMessageConverter"
class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter" />
</list>
</property>
</bean>

<!-- 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 conversion-service="applicationConversionService"/>

<!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources -->
<mvc:resources location="/, classpath:/META-INF/web-resources/" mapping="/resources/**"/>

<!-- Allows for mapping the DispatcherServlet to "/" by forwarding static resource
requests to the container's default Servlet -->
<mvc:default-servlet-handler/>

<!-- Register "global" interceptor beans to apply to all registered HandlerMappings -->
<mvc:interceptors>
<bean class="org.springframework.web.servlet.theme.ThemeChangeInterceptor"/>
<bean class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor" p:paramName="lang"/>
</mvc:interceptors>

<!-- Selects a static view for rendering without the need for an explicit controller -->
<mvc:view-controller path="/" view-name="welcome"/>
<mvc:view-controller path="/adminlistall" view-name="request/adminlistall"/>
<mvc:view-controller path="/uncaughtException"/>
<mvc:view-controller path="/resourceNotFound"/>
<mvc:view-controller path="/dataAccessFailure"/>


<!-- Resolves localized messages*.properties and application.properties files in the application to allow for internationalization.
The messages*.properties files translate Roo generated messages which are part of the admin interface, the
application.properties resource bundle localizes all application specific messages such as entity names and menu items. -->
<bean class="org.springframework.context.support.ReloadableResourceBundleMessageSource" id="messageSource" p:basenames="WEB-INF/resources/messages" p:fallbackToSystemLocale="false"/>

<!-- Store preferred language configuration in a cookie -->
<bean class="org.springframework.web.servlet.i18n.CookieLocaleResolver" id="localeResolver" p:cookieName="locale"/>

<!-- Resolves localized <theme_name>.properties files in the classpath to allow for theme support -->
<bean class="org.springframework.ui.context.support.ResourceBundleThemeSource" id="themeSource"/>

<!-- Store preferred theme configuration in a cookie -->
<bean class="org.springframework.web.servlet.theme.CookieThemeResolver" id="themeResolver" p:cookieName="theme" p:defaultThemeName="standard"/>


<!-- This bean resolves specific types of exceptions to corresponding logical - view names for error views.
The default behaviour of DispatcherServlet - is to propagate all exceptions to the servlet
container: this will happen - here with all other types of exceptions. -->
<bean class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver" p:defaultErrorView="uncaughtException">
<!-- <property name="com.pkg.GDS.exceptionMappings">
<props>
<prop key=".DataAccessException">dataAccessFailure</prop>
<prop key=".NoSuchRequestHandlingMethodException">resourceNotFound</prop>
<prop key=".TypeMismatchException">resourceNotFound</prop>
<prop key=".MissingServletRequestParameterException">resourceNotFound</prop>
</props>
</property> -->
</bean>

<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<!-- one of the properties available; the maximum file size in bytes 20 MB-->
<property name="maxUploadSize" value="20971520"/>
</bean>

<bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">
<property name="mediaTypes">
<map>
<entry key="html" value="text/html"/>
<entry key="json" value="application/json"/>
<entry key="xml" value="application/xml" />
</map>
</property>
<property name="viewResolvers">
<list>
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/views/"/>
<property name="suffix" value=".jsp"/>
</bean>
</list>
</property>
<property name="defaultViews">
<list>
<bean
class="org.springframework.web.servlet.view.json.MappingJacksonJsonView" />
<bean class="org.springframework.web.servlet.view.xml.MarshallingView">
<constructor-arg>
<bean class="org.springframework.oxm.xstream.XStreamMarshaller"
p:autodetectAnnotations="false" />
</constructor-arg>
</bean>

</list>
</property>
<property name="defaultContentType" ref="jsonMediaType" />
<property name="ignoreAcceptHeader" value="false" />
</bean>
<bean id="jsonMediaType" class="org.springframework.http.MediaType">
<constructor-arg value="application"/>
<constructor-arg value="json"/>
</bean>
<bean class="com.pkg.GDS.web.ApplicationConversionServiceFactoryBean" id="applicationConversionService"/>


My Controller



@RequestMapping(value = "/update", method = RequestMethod.GET)
public String update(@RequestParam(value="id", required=true) Long id, Model model, HttpServletRequest request) {
logger.log(Level.INFO, "updateForm");
Request userrequest = requestService.findrequestById(id);
model.addAttribute("request", userrequest);
return "request/update";
}


The view is not rendered instead it display the jsp page as text. Am I missing something?


-Sowmya


Aucun commentaire:

Enregistrer un commentaire