i am integrating spring-jersey. i am trying to inject property without annotation(@InjectParam). this code is not working.I strictly need it to inject without using annotation.
here is my Web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4"
xmlns="http://ift.tt/qzwahU"
xmlns:xsi="http://ift.tt/ra1lAU"
xsi:schemaLocation="http://ift.tt/qzwahU http://ift.tt/16hRdKA">
<display-name>Jersey Example</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>\WEB-INF\dispatcher-servlet.xml</param-value>
</context-param>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<servlet>
<servlet-name>jersey</servlet-name>
<servlet-class>
com.sun.jersey.spi.container.servlet.ServletContainer
</servlet-class>
<init-param>
<param-name>com.sun.jersey.spi.spring.container.servlet.SpringServlet</param-name>
<param-value>org.jersey.examples</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>jersey</servlet-name>
<url-pattern>/jersey/*</url-pattern>
</servlet-mapping>
</web-app>
dispatcher-servlet.xml
<beans xmlns="http://ift.tt/GArMu6"
xmlns:xsi="http://ift.tt/ra1lAU" xmlns:context="http://ift.tt/GArMu7"
xsi:schemaLocation="http://ift.tt/GArMu6
http://ift.tt/QEDs1e
http://ift.tt/GArMu7
http://ift.tt/QEDs1k">
<context:component-scan base-package="org.jersey.examples" />
<bean id="springBean" class="org.jersey.examples.SpringBeanExample" />
<bean id="jerseySimple" class="org.jersey.examples.JerseySimpleExample">
<property name="springBean" value="springBean" />
</bean>
</beans>
SpringBeanExample.java
package org.jersey.examples;
public class SpringBeanExample{
public String getValue(){
return "Spring and Jersey Integration";
}
}
JerseySimpleExample.java
package org.jersey.examples;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.core.Response;
import org.springframework.stereotype.Component;
@Component
@Path("/hello")
public class JerseySimpleExample {
private SpringBeanExample springBean;
@GET
@Path("/javabeat")
public Response getMessage() {
String result = springBean.getValue();
return Response.status(200).entity(result).build();
}
public void setSpringBean(SpringBeanExample springBean) {
this.springBean = springBean;
}
}
When I hit the URL webservice doesnot get hit. This code works properly when i use @InjectParam and remove jerseySample bean from dispatcher-servlet.xml. please help.
Aucun commentaire:
Enregistrer un commentaire