CAS: Attributes don't show up at CAS client - cas

I can't get the attributes to the CAS client.
I did some research and try to find out how to forward attributes to a CAS client.
In the cas.properties I set this:
cas.principal.resolver.persondir.return.null=false
I added this dependency:
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
<version>4.1</version>
</dependency>
This is my servicesRegistry.conf:
{
"services":[
{
"id":1,
"serviceId":"https://localhost:8743/**",
"name":"HELLO_WORLD",
"description":"WEBAPP FOR TESTS",
"theme":"my_example_webapp",
"allowedToProxy":true,
"enabled":true,
"ssoEnabled":true,
"anonymousAccess":false,
"evaluationOrder":1,
"attributeReleasePolicy" : {
"#class" : "org.jasig.cas.services.ReturnAllowedAttributeReleasePolicy",
"principalAttributesRepository" : {
"#class" : "org.jasig.cas.authentication.principal.DefaultPrincipalAttributesRepository"
},
"allowedAttributes" : [ "java.util.ArrayList", [ "cn", "description", "telephoneNumber" ] ]
}
},
{
"id":2,
"serviceId":"https://yahoo.com",
"name":"YAHOO",
"description":"Test service with exact match on its serviceId and optional extra attributes",
"extraAttributes":{
"someCustomAttribute":"Custom attribute value"
},
"evaluationOrder":2
}
]
}
My ldapAuthenticationHandlerlooks like this:
<bean id="ldapAuthenticationHandler"
class="org.jasig.cas.authentication.LdapAuthenticationHandler"
p:principalIdAttribute="cn"
c:authenticator-ref="authenticator">
<property name="principalAttributeMap">
<map>
<entry key="cn" value="cn" />
<entry key="description" value="description" />
<entry key="telephoneNumber" value="telephoneNumber" />
</map>
</property>
</bean>
And my authenticationHandlersResolvers like this:
<util:map id="authenticationHandlersResolvers">
<entry key-ref="ldapAuthenticationHandler" value="#{null}" />
</util:map>
And here is my attributeRepository:
<bean id="attributeRepository" class="org.jasig.services.persondir.support.NamedStubPersonAttributeDao"
p:backingMap-ref="attrRepoBackingMap" />
<util:map id="attrRepoBackingMap">
<entry key="cn" value="cn" />
<entry key="description" value="description" />
<entry key="telephoneNumber" value="telephoneNumber" />
<entry>
<key><value>memberOf</value></key>
<list>
<value>faculty</value>
<value>staff</value>
<value>org</value>
</list>
</entry>
</util:map>
And at the client side I do this (edited version with out null check etc):
AttributePrincipal principal = (AttributePrincipal) request.getUserPrincipal();
final Map attributes = principal.getAttributes();
Iterator attributeNames = attributes.keySet().iterator();
String attributeName = (String) attributeNames.next();
However, I don't get any attributes. What am I missing?
EDIT:
I read in another thread that I have to change Cas20ProxyReceivingTicketValidationFilterto Cas30ProxyReceivingTicketValidationFilter, but that didn't change anything:
<filter>
<filter-name>CAS Validation Filter</filter-name>
<filter-class>org.jasig.cas.client.validation.Cas30ProxyReceivingTicketValidationFilter</filter-class>
<init-param>
<param-name>casServerUrlPrefix</param-name>
<param-value>https://localhost:8943/cas</param-value>
</init-param>
<init-param>
<param-name>serverName</param-name>
<param-value>https://localhost:8743</param-value>
</init-param>
<init-param>
<param-name>redirectAfterValidation</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>useSession</param-name>
<param-value>true</param-value>
</init-param>
</filter>

My problem was the servicesRegistry.conf. It didn't work for some reason and I couldn't figure out why.
If you have problem using the servicesRegistry.conf file, I recommend you use this inside your deployerConfigContext.xml:
<bean id="serviceRegistryDao" class="org.jasig.cas.services.InMemoryServiceRegistryDaoImpl">
<property name="registeredServices">
<list>
<bean class="org.jasig.cas.services.RegexRegisteredService"
p:id="5" p:name="https.all" p:description="Allow HTTPS connection"
p:serviceId="^https://.*" p:evaluationOrder="5" >
<property name="attributeReleasePolicy">
<bean class="org.jasig.cas.services.ReturnAllAttributeReleasePolicy" />
</property>
</bean>
</list>
</property>
</bean>
This will allow all services that have an URL that fits the regex ^https://.*.

Related

Spring 4 Controller not converting JSON to Java class

I'm tryng to convert JSON into a java class using Spring.
When I execute the code I get 400 bad request.
If I replace User java object (#RequestBody final **User** user) with generic java Oject (#RequestBody final **Object** user), I get the json string as parameter.
Here's my code.
Javascript:
register : function(usr,pwd) {
var user = {username : usr, password: pwd}
return $http({
method: 'POST',
url: '/SpringSecurityRememberMeAnnotationExample/newuser',
contentType: "application/json",
data:user
});
/*
return $http.post('/SpringSecurityRememberMeAnnotationExample/newuser', user).then(function(response) {
return response.data;
});
*/
},
Controller:
#Controller
#Scope("request")
public class HomeController {
#RequestMapping(value = "/newuser", method = RequestMethod.POST)
#ResponseBody public User SaveUser(#RequestBody final User user){
System.out.println("username: ");// + user.username);
System.out.println("password: ");// + user.password);
return null;
}
spring-mvc.xml
<mvc:annotation-driven/>
<mvc:default-servlet-handler/>
<!-- Login Interceptor -->
<mvc:interceptors>
<mvc:interceptor>
<mvc:mapping path="/**"/>
<bean class="com.websystique.springsecurity.interceptor.LoginInterceptor"/>
</mvc:interceptor>
<!-- workaround to fix IE8 problem -->
<bean id="webContentInterceptor"
class="org.springframework.web.servlet.mvc.WebContentInterceptor">
<property name="cacheSeconds" value="0"/>
<property name="useExpiresHeader" value="true"/>
<property name="useCacheControlHeader" value="true"/>
<property name="useCacheControlNoStore" value="true"/>
</bean>
</mvc:interceptors>
<!-- i18n -->
<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="useCodeAsDefaultMessage" value="true"/>
<property name="basename" value="WEB-INF/i18n"/>
<property name="defaultEncoding" value="UTF-8"/>
<property name="fileEncodings" value="UTF-8" />
</bean>
<bean id="localeResolver" class="org.springframework.web.servlet.i18n.FixedLocaleResolver">
<property name="defaultLocale" value="it"/>
<property name="useCodeAsDefaultMessage" value="true"/>
</bean>
<!-- Exception handler -->
<bean id="exceptionResolver"
class="org.springframework.web.servlet.handler.SimpleMappingExceptionResolver">
<property name="exceptionMappings">
<props>
<prop key="LoginRequiredException">
public/loginRequired
</prop>
<prop key="ResourceNotFoundException">
public/notFound
</prop>
</props>
</property>
<property name="defaultErrorView" value="rescues/general" />
</bean>
<!-- View Handler -->
<bean id="jspViewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass"
value="org.springframework.web.servlet.view.JstlView" />
<property name="prefix" value="/WEB-INF/views/" />
<property name="suffix" value=".jsp" />
<property name="order" value="0" />
</bean>
<bean id="jacksonMessageConverter" class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter" />
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
<property name="messageConverters">
<list>
<ref bean="jacksonMessageConverter"/>
</list>
</property>
</bean>
Thank you!
Adding POM.XML config, json part
<!-- JSon -->
<dependency>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-json-provider</artifactId>
<version>2.6.4</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.6.4</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.6.4</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.9.13</version>
</dependency>
Recheck the setters/getters for the fields and make sure there is a no-argument constructor. (If you have no constructor, Java will generate a default no-arg one, but if you have added a constructor with arguments yourself, you must take care to implement a no-arg one as well).
Main Problem was on the User class embedded on the controller code. Once I created User.java file on it's own package all goes smoothly.
You are passing malformed json object i guess. you should pass user json data like below.
var user = {"username" : "<username>", "password": "<password>"};
And makes sure User.java has setters/getters for the fields and default constructor.
Please make sure following two jars are present in your application
1. Jackson - core
2. Jackson - mapper
Both Java API are used by spring for XML/JSON processing.
put var user = {"username" : usr, "password": pwd}; in java script,
and do confirm that your User class is right having proper setter getter and proper access to your calling class.

Migration from Spring 3 to Spring 4.1 HTTP Status 406 with Ajax/JSON request

I have migrated my application from Spring 3 to Spring 4.1.7.
Now, when i a doing an ajax query, the server responds with an HTTP 406 error.
POST /extranet/EmailIdentificationGetFicheClient.html HTTP/1.1
Host: localhost
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.0
Accept: application/json, */*; q=0.01
Accept-Language: fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
The response :
HTTP/1.1 406 Inacceptable Server: Apache-Coyote/1.1 Content-Type:
text/html;charset=utf-8 Content-Language: fr Content-Length: 1110
Date: Wed, 26 Aug 2015 08:28:08 GMT
I have the latest jackson librairies in the classpath :
<dependency org="com.fasterxml.jackson.datatype" name="jackson-datatype-json-org" rev="2.6.1" />
<dependency org="org.codehaus.jackson" name="jackson-mapper-asl" rev="1.9.13" />
My dispatcher-servlet.xml
<mvc:annotation-driven>
<mvc:message-converters register-defaults="true">
<bean class = "org.springframework.http.converter.StringHttpMessageConverter">
<property name="supportedMediaTypes" value="text/plain; charset=UTF-8" />
</bean>
<bean class="org.springframework.http.converter.xml.Jaxb2RootElementHttpMessageConverter">
<property name="supportedMediaTypes" value="application/xml"/>
</bean>
<bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
<property name="supportedMediaTypes" value="application/json"/>
</bean>
</mvc:message-converters>
</mvc:annotation-driven>
<bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">
<property name="favorPathExtension" value="false" />
<property name="useJaf" value="false" />
<property name="useNotAcceptableStatusCode" value="false" />
<property name="viewResolvers">
<list>
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
<property name="order" value="1" />
</bean>
</list>
</property>
<property name="defaultViews">
<list>
<bean class="org.springframework.web.servlet.view.json.MappingJackson2JsonView" />
</list>
</property>
As the application lives along with struts, the spring servlet was mapped to *.html URLs.
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>*.html</url-pattern>
</servlet-mapping>
We have several ajax queries such as this one :
$.ajax({
type : "post",
accepts : {
json : 'application/json'
},
url : "/extranet/emailIdentification.html",
cache : false,
dataType : 'json', ...
The controller code (i can see in debug that it gets correctly there).
#RequestMapping(value="/extranet/EmailIdentification")
#ResponseBody
public Contact getContactFromEmail(HttpServletRequest request) throws SpringException {
Additionnaly, we are using spring-security and what we are trying to do is get spring to recognize the accept header as it did on the previous version.
Thank you for your time.
I have finally found where my problem was.
The problem was not caused by the jackson librairies for my part as they were correctly loaded.
I noticed in debug that i received an exception HttpMediaTypeNotAcceptableException.
This exception was caused by the ContentNegotiationStrategy loaded was using the path extension instead of the HTTP headers, although i configured the view resolver to ignore path extension :
<bean
class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">
<property name="favorPathExtension" value="false" />
<property name="useJaf" value="false" />
<property name="useNotAcceptableStatusCode" value="false" />
<property name="viewResolvers">
I also added a Content Manager Factory :
<bean id="cnManager" class="org.springframework.web.accept.ContentNegotiationManagerFactoryBean">
<property name="favorPathExtension" value="false" />
<property name="useJaf" value="false" />
<property name="ignoreAcceptHeader" value="false" />
</bean>
But this factory was never taken into account, instead, spring loaded its own version called mvcContentNegotiationManager.
The final hack was therefore to force using the correct class and this is done by setting it through the mvc:annotation-driven tag :
<mvc:annotation-driven content-negotiation-manager="cnManager" />
Et Voilà. Now i can still use the .html extension in spring 4 even for json queries.
The cause of the problem is inability of Spring to load Jackson. It is not loaded by dependencies by default. After I've added the dependency
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-jaxrs</artifactId>
<version>1.9.2</version>
</dependency>
the JSON was returned after typing the address in the browser, without any tricks with Accept headers (as it is supposed to do).

Way to map Spring viewresolver to html file

I am doing project on Spring MVC with html file as viewResolver. Already my project done in ftl (freemarker template) files as viewResolver perfectly. But I want to do conversion of all ftl files into html files. Hence I have tried hard for two days and do some configuration changes in view resolver like below, but nothing worked.
My original code in applicationContext.xml
<bean id="viewResolver"
class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver">
<property name="cache" value="true" />
<property name="prefix" value="/WEB-INF/views/" />
<property name="suffix" value=".ftl" />
<property name="exposeSpringMacroHelpers" value="true" />
<property name="exposeRequestAttributes" value="true" />
<property name="allowRequestOverride" value="false" />
<property name="exposeSessionAttributes" value="true" />
<property name="allowSessionOverride" value="false" />
<property name="exposePathVariables" value="true" />
<property name="requestContextAttribute" value="rc" />
</bean>
I have made some changes like below
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/views/" />
<property name="suffix" value=".html" />
</bean>
My DispatcherServlet configuration
<servlet>
<servlet-name>appServlet</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>appServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
My html files are in "/WEB-INF/views/" folder. What changes I need to do to run the html files. Any alternate way also warmly welcome. Thanks in advance guys...
HTML pages meant for implementing static views, we have great feature in spring to render the static resources like html, css and images i.e.
<mvc:resources mapping="/static/**" location="/WEB-INF/static/" />
Similar question asked here SpringViewResolver for HTML views
================================ SOLUTION ========================================
Newly created Folder structure:
WEB-INF
`-static
|-html
`-index.html
Spring config:
<resources mapping="/static/**" location="/WEB-INF/static/" />
<beans:bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<beans:property name="prefix" value="" />
<beans:property name="suffix" value=".html" />
</beans:bean>
My web.xml
<servlet>
<servlet-name>appServlet</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>appServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
Controller method:
#RequestMapping(value = "/", method = RequestMethod.GET)
public String homePage(ModelMap model, HttpServletRequest servletRequest, HttpServletResponse response) {
String returnText = "static/html/index";
return returnText;
}
I have searched and implemented various ways. Its now working like a boss.
Below link helped me and stiched my time a lot. Also need to work various html files with this solution.
Spring MVC ViewResolver not mapping to HTML files

JSON getting encoded after returning from controller

A Spring controller has the following method :
#RequestMapping(value = "reportsOverall.html")
public/* #ResponseBody */
ModelAndView reportsOverall(SearchParameters searchParameters) {
searchParameters = new SearchParameters(840, "SCH_01", "PRM_07");
System.out.println("Inside controller");
String result = overallDetailsService
.getOverallDetails(searchParameters);
System.out.println("result is " + result);
Map<String, String> model = new HashMap<String, String>();
model.put("data", result);
ModelAndView modelAndView = new ModelAndView("reports/reportsOverall",
model);
return modelAndView;
}
I get the expected output on the server-side console :
result is { "_id" : { "SpId" : 840 , "Scheduler_id" : "SCH_01"} , "positive_count" : 64 , "neutral_count" : 78 , "negative_count" : 2}
But in the reportsOverall.jsp, when I retrieve the result object as :
function drawSentimentPieChart() {
var data = '<c:out value="${data}"/>';
alert(data);
var dataJson = JSON.parse(data);
......
}
in the alert I get :
{ "_id" : { "SpId" : 840 , "Scheduler_id" : "SCH_01"} , "positive_count" : 64 , "neutral_count" : 78 , "negative_count" : 2}
The space and "" quotes are encoded here, thereby, causing the parse to fail.
The spring-servlet.xml is :
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<mvc:annotation-driven />
<context:component-scan base-package="com.lnt" />
<bean id="restTemplate" class="org.springframework.web.client.RestTemplate"></bean>
<!-- <bean
class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
<property name="messageConverters">
<array>
<bean
class="org.springframework.http.converter.StringHttpMessageConverter">
<property name="supportedMediaTypes" value="text/plain;charset=UTF-8" />
</bean>
</array>
</property>
</bean> -->
<bean id="jacksonMessageConverter"
class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter" />
<bean id="viewResolver"
class="org.springframework.web.servlet.view.UrlBasedViewResolver">
<property name="viewClass"
value="org.springframework.web.servlet.view.JstlView" />
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
</bean>
<bean id="messageSource"
class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="basenames"
value="classpath:userProfile,classpath:default,classpath:messages,classpath:customerAdmin,classpath:reports,classpath:superAdmin" />
<property name="defaultEncoding" value="UTF-8" />
</bean>
<bean id="dateFormat" class="java.text.SimpleDateFormat">
<constructor-arg value="yyyy-MM-dd hh:mm:ss" />
</bean>
</beans>
I tried several things in the Spring controller :
Using #ResponseBody; in this case, I got a dump on the page like this but the page wasn't rendered properly :
{"view":null,"model":{"data":"{ \"_id\" : { \"SpId\" : 840 , \"Scheduler_id\" : \"SCH_01\"} , \"positive_count\" : 64 , \"neutral_count\" : 78 , \"negative_count\" : 2}"},"empty":false,"viewName":"reports/reportsOverall","reference":true,"modelMap":{"data":"{ \"_id\" : { \"SpId\" : 840 , \"Scheduler_id\" : \"SCH_01\"} , \"positive_count\" : 64 , \"neutral_count\" : 78 , \"negative_count\" : 2}"}}
Added encoding filter to the web.xml :
<filter>
<filter-name>encoding-filter</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-mapping>
<filter-name>encoding-filter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
Attempted using MappingJacksonJsonView in vain !
What is that I'm overlooking?
I had the same problem, but this additional attribute saved me:
<c:out value="${data}" escapeXml="false"/>

configuring the jacksonObjectMapper not working in spring mvc 3

What I am aiming to do is to configure spring mvc 3 to not return “null” object in json response.
I've asked the question how to configure spring mvc 3 to not return "null" object in json response? . And the suggestion I got is to configure the ObjectMapper, setting the serialization inclusion to JsonSerialize.Inclusion.NON_NULL. So Based on Spring configure #ResponseBody JSON format, I did the following changes in spring config file. But I got the error "Rejected bean name 'jacksonObjectMapper': no URL paths identified org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping:86-AbstractDetectingUrlHandlerMapping.java" during app startup.
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
<!-- Configures the #Controller programming model -->
<mvc:annotation-driven />
<!-- Forwards requests to the "/" resource to the "welcome" view -->
<!--<mvc:view-controller path="/" view-name="welcome"/>-->
<!-- Configures Handler Interceptors -->
<mvc:interceptors>
<!-- Changes the locale when a 'locale' request parameter is sent; e.g. /?locale=de -->
<bean class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor" />
</mvc:interceptors>
<!-- Saves a locale change using a cookie -->
<bean id="localeResolver" class="org.springframework.web.servlet.i18n.CookieLocaleResolver" />
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
<property name="messageConverters">
<list>
<bean class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter">
<property name="objectMapper" ref="jacksonObjectMapper" />
</bean>
</list>
</property>
</bean>
<bean id="jacksonObjectMapper" class="org.codehaus.jackson.map.ObjectMapper" />
<bean id="jacksonSerializationConfig" class="org.codehaus.jackson.map.SerializationConfig"
factory-bean="jacksonObjectMapper" factory-method="getSerializationConfig" />
<bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
<property name="targetObject" ref="jacksonSerializationConfig" />
<property name="targetMethod" value="setSerializationInclusion" />
<property name="arguments">
<list>
<value type="org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion">NON_DEFAULT</value>
</list>
</property>
</bean>
<!-- Resolves view names to protected .jsp resources within the /WEB-INF/views directory -->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/views/"/>
<property name="suffix" value=".jsp"/>
</bean>
</beans>
I have no idea why it's been rejected. Any suggestion is greatly appreciated!
<mvc:annotation-driven /> and AnnotationMethodHandlerAdapter cannot be used together. (ref: spring forum thread). Possible solution
do not use <mvc:annotation-driven/>. Declaring bean: DefaultAnnotationHandlerMapping
and AnnotationMethodHandlerAdapter and other settings like validation, formatting.
use spring 3.1, which has <mvc:message-converters> (ref: Spring jira)