2016-03-21 13 views
2

私はuserIdをとり、HTML Webページ上のいくつかのユーザー評価情報を示すシンプルなWebサービスを実装しようとしています。Spring MVC WebサービスGET(Rest)コール:404

私はプログラム以下を実行しようとしたとき、私は404エラーを得たのスプリングMVCに

を使用して、いくつかの春の注釈ベースのWebサービスを書き込もうとしました。私が書いた

http://localhost:8080/EdgeStore/execute/user1

その簡単なプログラム。 このプログラムで何か不足していますか?

<?xml version="1.0" encoding="UTF-8"?> 

<beans xmlns="http://www.springframework.org/schema/beans" 
xmlns:context="http://www.springframework.org/schema/context" 
xmlns:mvc="http://www.springframework.org/schema/mvc" 
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-4.2.xsd 
     http://www.springframework.org/schema/context 
     http://www.springframework.org/schema/context/spring-context-4.2.xsd 
     http://www.springframework.org/schema/mvc 
     http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd"> 

     <context:component-scan base-package="EdgeStore"/> 

     <mvc:annotation-driven/> 

    </beans> 

とディスパッチャ

<?xml version="1.0" encoding="UTF-8"?> 
    <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns="http://java.sun.com/xml/ns/j2ee" 
    xmlns:web="http://xmlns.jcp.org/xml/ns/javaee" 
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
    http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" id="WebApp_ID" 
    version="2.4"> 

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

    <servlet-mapping> 
    <servlet-name>EdgeStore</servlet-name> 
    <url-pattern>/</url-pattern> 
</servlet-mapping> 
</web-app> 

され、コントローラが

package EdgeStore; 

import org.springframework.stereotype.Controller; 
import org.springframework.web.bind.annotation.PathVariable; 
import org.springframework.web.bind.annotation.RequestBody; 
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.bind.annotation.ResponseStatus; 

@Controller 
@RequestMapping("/execute") 
    public class executeController { 

    @RequestMapping(value="/{userId}", method = RequestMethod.GET) 
    @ResponseBody 
    public UserProfile getUserProfile(@PathVariable("userId") String userId) { 
     UserProfile userProfile = new UserProfile(); 
     userProfile.setUserId(userId); 
     userProfile.setSegmentId("defaultSegement"); 
     return userProfile; 
    } 
} 
+0

/」を「/*」に設定してみましたか? –

+0

ありがとうPatrick、私は "/ *"と "/EdgeStore"の両方を試しました –

答えて

0

あなたはこの形式であなたのディスパッチャを変更してみてくださいすることができます:

<display-name>EdgeStore</display-name> 
    <servlet> 
      <servlet-name>EdgeStore</servlet-name> 
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> 
     <init-param> 
     <param-name>contextConfigLocation</param-name> 
// Give location for your config file. 
     <param-value>/WEB-INF/spring/appServlet/servlet-context.xml</param-value> 
    </init-param> 
    <load-on-startup>1</load-on-startup> 
    </servlet> 

    <servlet-mapping> 
    <servlet-name>EdgeStore</servlet-name> 
    <url-pattern>/</url-pattern> 
</servlet-mapping> 

これがない場合仕事、私に教えてください。私は私の答えを取り除きます。

+0

申し訳ありません "私たちはボルグです"、それでも動作しません。 –

+0

重要なデータなしでプロジェクトをパッケージ化して送信できますか?私はここで何が問題かをより早くチェックすることができます。 Lemmeは知っている。 –

+0

https://drive.google.com/open?id=0B1mAaSOgT6y2WEFMa2lMRm41eWc –