2016-09-22 4 views
0

пытается приложение весной отдых и получить 404, я не в состоянии выяснить проблему, консоль сервера ничего не показывает о проблеме, ниже код404 - основная пружина остальное сбой и показывает 404 ошибки

there were many posts for this problem, i checked them did modifications also, none worked 
could any body please give the solution to this.Thank you 

это контроллер

@RestController 
@RequestMapping("/service") 
public class SpringServiceController { 
    @RequestMapping(value = "/{name}", method = RequestMethod.GET) 
    public String getGreeting(@PathVariable String name) { 
     String result="Hello "+name; 
     System.out.println("in the controller"); 
     return result; 
    } 
} 

web.xml

<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"> 
    <display-name>springRest</display-name> 
    <welcome-file-list> 
     <welcome-file>index.jsp</welcome-file> 
    </welcome-file-list> 

    <servlet> 
     <servlet-name>rest</servlet-name> 
     <servlet-class> 
      org.springframework.web.servlet.DispatcherServlet 
     </servlet-class> 
     <load-on-startup>1</load-on-startup> 
    </servlet> 

    <servlet-mapping> 
     <servlet-name>rest</servlet-name> 
     <url-pattern>/*</url-pattern> 
    </servlet-mapping> 

    <context-param> 
      <param-name>contextConfigLocation</param-name> 
      <param-value>/WEB-INF/rest-servlet.xml</param-value> 
    </context-param> 

     <listener> 
      <listener-class> 
       org.springframework.web.context.ContextLoaderListener 
      </listener-class> 
     </listener> 


    <session-config> 
     <session-timeout>30</session-timeout> 
    </session-config> 
</web-app> 

это отдых-servlet.xml

<?xml version="1.0" encoding="UTF-8"?> 
<beans xmlns="http://www.springframework.org/schema/beans" 
    xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:context="http://www.springframework.org/schema/context" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation=" 
     http://www.springframework.org/schema/beans  
     http://www.springframework.org/schema/beans/spring-beans.xsd 
     http://www.springframework.org/schema/mvc 
     http://www.springframework.org/schema/mvc/spring-mvc.xsd 
     http://www.springframework.org/schema/context 
     http://www.springframework.org/schema/context/spring-context.xsd"> 

    <mvc:annotation-driven /> 
    <context:component-scan base-package="com.org.vasu.springRest.controller.*" /> 




</beans> 
+0

вы можете попробовать добавить @ResponseBody над методом getGreeting – user3470953

+0

@ user3470953 --- спасибо не реагирует никаких изменений, его ту же ошибку, ниже приведены 2 строки отображаются на консоли сервера org.springframework .web.servlet.PageNotFound noHandlerFound ПРЕДУПРЕЖДЕНИЕ: сопоставление не найдено для HTTP-запроса с URI [/ springRest /] в DispatcherServlet с именем «rest» – user1245524

+0

использовать «/» при сопоставлении;/ user3470953

ответ

0
<context:component-scan base-package="com.org.vasu.springRest.controller" /> 
+0

спасибо, что это сработало – user1245524

Смежные вопросы