ERLEDIGT
NEIN
NEIN
ANTWORTEN
0
0
ZUGRIFFE
868
868
EMPFEHLEN
-
08.06.09 09:45 #1
- Registriert seit
- Jun 2009
- Beiträge
- 1
hallo...
Ich spiele gerade mit Jersey und Spring herum. Ist es möglich, dass man Jersey dann auch ein ModelAndView - Objekt zurück gibt? Kann man ein ViewResolver in der xml definieren?
Code java:1 2 3 4 5 6 7 8 9 10 11
@Component @PerRequest @Scope("prototype") @Path("/test") public class Test { @GET @Produces("text/html") public ModelAndView getIt() { return new ModelAndView("view"); } }
Ich bekomme folgende Fehlermeldung:
A message body writer for Java type, class org.springframework.web.servlet.ModelAndView, and MIME media type, text/html, was not found
Meine web.xml
ApplicationContext.xmlHTML-Code:<?xml version="1.0" encoding="UTF-8"?> <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:applicationContext.xml</param-value> </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <listener> <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class> </listener> <servlet> <servlet-name>Jersey Spring Web Application</servlet-name> <servlet-class>com.sun.jersey.spi.spring.container.servlet.SpringServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>Jersey Spring Web Application</servlet-name> <url-pattern>/webresources/*</url-pattern> </servlet-mapping> </web-app>
HTML-Code:<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd"> <context:component-scan base-package="example.jersey.spring"/> <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/jsp/"/> <property name="suffix" value=".jsp"/> </bean> </beans>
Geändert von Micvkey166 (08.06.09 um 11:04 Uhr) Grund: Ergänzung
Ähnliche Themen
-
Restful Webservices with Jersey and Java - Tutorial
Von vogella im Forum Java Technology NewsAntworten: 0Letzter Beitrag: 18.02.10, 04:33 -
Hellowebservice mit Jersey?
Von flashray im Forum Enterprise Java (JEE, J2EE, Spring & Co.)Antworten: 2Letzter Beitrag: 25.06.08, 11:47





Zitieren
Login





