spring和angulaJS(我收到HTTP状态404错误)

时间:2016-05-17 09:42:18

标签: javascript java angularjs spring

我的控制器出现HTTP Status 404错误。

服务器代码

@RequestMapping(value="/showMsg/",
method=RequestMethod.GET,produces=
{
"application/json"
})'

public ResponseBody String show(){
    HashMap hash = new HashMap();
    hash.put("msg", "welcome to spring angular js");
    return hash;
}

AngularJS代码

$http.get('HelloWorld/showMsg').success(function(data){
    alert("Success");
}).error(function(data){
    alert("Error");
});

我收到HTTP Status 404错误。

1 个答案:

答案 0 :(得分:0)

在这种情况下,网址有误。

定义正确的URL,如下所示:

$http.get('http://localhost:8000/HelloWorld/showMsg')
相关问题