Can anyone tell me please if what i am doing is right ?
I have this web.xml file with my servlets declared inside, i wanted to creat another servlet that access [reach] the same webservice
it doesn't work and i don't know what i am missing can you help please ? Here is my servlets and code:
<!-- old servlet-->
<servlet>
<servlet-name>api</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring-config/api-r-servlet.xml</param-value>
</init-param>
<load-on-startup>3</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>api</servlet-name>
<url-pattern>/sitesApi/*</url-pattern>
</servlet-mapping>
<!-- my secod servmet V2 -->
<servlet>
<servlet-name>webservice</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring-config/api-web-servlet.xml</param-value>
</init-param>
<load-on-startup>3</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>webservice</servlet-name>
<url-pattern>/api/*</url-pattern>
</servlet-mapping>
So for my other XML file, api-web-servlet it's quite the same :
<?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"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="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.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd"
>
<context:annotation-config/>
<context:component-scan base-package="com.me.project.rest.api" />
<mvc:annotation-driven />
</beans>
for my URL test i use: http://localhost:8080/sitesApi/v1/mysite?id=1&fields=site.name and it works but when i try with the other servlet it doesnt : http://localhost:8080/api/v1/mysite?id=1&fields=site.name
******* Edition*****
@RequestMapping(value = "/v1/mySite", method = RequestMethod.GET)
public @ResponseBody
Object SitesV1( @RequestParam(value = "ajouterstatus", required = false) Integer ajouterstatus,
@RequestParam(value = "monadresse", required = false) String monadresseHttpServletRequest request, HttpServletResponse responseHttp{
try {
appname = request.getHeaders( "Name" ).nextElement().toString();
} catch ( Exception e ) {
return new Result( "", ": AppName is Empty" );
}
So exactly the same thing with the other method
@RequestMapping(value = "/v2/mySite", method = RequestMethod.GET)
public @ResponseBody
Object SitesV2( @RequestParam(value = "ajouterstatus", required = false) Integer ajouterstatus,
@RequestParam(value = "monadresse", required = false) String monadresseHttpServletRequest request, HttpServletResponse responseHttp{
try {
appname = request.getHeaders( "Name" ).nextElement().toString();
} catch ( Exception e ) {
return new Result( "", ": AppName is Empty" );
}
Any idea ?? Thank you