私はSpring Restful Serviceを初めて使用し、以下のURLを入力したときに異なる形式で結果を取得したい-----
localhost:7001/SpringRestService/restful/methodName/ALL/ALL/ALL/ALL.xml
localhost:7001/SpringRestService/restful/methodName/ALL/ALL/ALL/ALL.json
localhost:7001/SpringRestService/restful/methodName/ALL/ALL/ALL/ALL.pdf
しかし、サーバーを起動すると以下のエラーが発生します----
<Servlet: "SpringRest" failed to preload on startup in Web application: "SpringRestService".
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.view.ContentNegotiatingViewResolver#0' defined in ServletContext resource [/WEB-INF/SpringRest-servlet.xml]: Cannot create inner bean 'org.springframework.web.servlet.view.UrlBasedViewResolver#20e0f98' of type [org.springframework.web.servlet.view.UrlBasedViewResolver] while setting bean property 'viewResolvers' with key [0]; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.view.UrlBasedViewResolver#20e0f98' defined in ServletContext resource [/WEB-INF/SpringRest-servlet.xml]: Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: Property 'viewClass' is required
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:282)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:121)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveManagedList(BeanDefinitionValueResolver.java:353)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:154)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1391)
Truncated. see log file for complete stacktrace
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.view.UrlBasedViewResolver#20e0f98' defined in ServletContext resource [/WEB-INF/SpringRest-servlet.xml]: Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: Property 'viewClass' is required
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:532)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:461)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveInnerBean(BeanDefinitionValueResolver.java:271)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:121)
at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveManagedList(BeanDefinitionValueResolver.java:353)
Truncated. see log file for complete stacktrace
java.lang.IllegalArgumentException: Property 'viewClass' is required
-----------------------springRest-servlet.xml---------------------- -------
<?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:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<!-- Specify a view resolver for JSP files-->
<bean id="viewResolvers" class="org.springframework.web.servlet.view.InternalResourceViewResolver"
p:prefix="/WEB-INF/view/" p:suffix=".jsp" />
<bean class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver">
<property name="mediaTypes">
<map>
<entry key="xml" value="application/xml"/>
<entry key="html" value="text/html"/>
</map>
</property>
<property name="viewResolvers">
<list>
<bean class="org.springframework.web.servlet.view.UrlBasedViewResolver"/>
</list>
</property>
<property name="defaultViews">
<list>
<bean class="org.springframework.web.servlet.view.json.MappingJacksonJsonView" />
</list>
</property>
</bean>
</beans>
-----------------------------my controller class------------------------------
以下は私のコントローラークラスです
package org.nea.rest.unsr;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.nea.ia.services.util.uniserv.UniServGrantInfo;
import org.nea.spring.services.interfaces.uniservs.UniservSearchInterface;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
@Controller
public class HelloWorldController1 {
@Autowired
UniservSearchInterface uniservService;
public UniservSearchInterface getUniservService() {
return uniservService;
}
public void setUniservService(UniservSearchInterface uniservService) {
this.uniservService = uniservService;
}
protected final Log logger = LogFactory.getLog(getClass());
/* commented
@RequestMapping(value = "/showAllGrants/{userName}/{year}/{status}/{stateId}", method = RequestMethod.GET)
public @ResponseBody
List<UniServGrantInfo> getTextFromURL(@PathVariable("userName") String userName, @PathVariable("year") String year,
@PathVariable("status") String status, @PathVariable("stateId") String stateId) {
List<UniServGrantInfo> grantInfoList = new ArrayList<UniServGrantInfo>();
grantInfoList = uniservService.showAllgrants(userName, year, status, stateId);
return grantInfoList;
}
*/
@RequestMapping(value = "/showAllGrants/{userName}/{year}/{status}/{stateId}", method = RequestMethod.GET)
public ModelAndView getTextFromURL(@PathVariable("userName") String userName, @PathVariable("year") String year,
@PathVariable("status") String status, @PathVariable("stateId") String stateId) {
List<UniServGrantInfo> grantInfoList = new ArrayList<UniServGrantInfo>();
grantInfoList = uniservService.showAllgrants(userName, year, status, stateId);
ModelAndView model = new ModelAndView("index");
//ModelAndView mav = new ModelAndView();
// mav.setViewName("index");
// mav.addObject("sampleContentList", grantInfoList);
return model;
}
}
can anybody help me telling where i am doing wrong or if i am missing any required jar file.