spring和angularJS(我得到了类似HTTP状态404的错误)

spring and angulaJS(i am getting error like HTTP Status 404 )

本文关键字:状态 HTTP 错误 angularJS spring      更新时间:2023-09-26

我的控制器中出现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错误。

URL在这种情况下是错误的。

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

$http.get('http://localhost:8000/HelloWorld/showMsg')