【发布时间】:2018-06-19 10:23:27
【问题描述】:
我需要帮助
我正在使用 spring 框架开发一个使用 angular 和 restful web 服务的应用程序
从 RESTController 调用此方法后
@CrossOrigin(origins = "http://localhost:4200")
@RequestMapping(value="/search",method=RequestMethod.GET)
public Page<Bien> chercher(
@RequestParam(name="mc",defaultValue="") String mc,
@RequestParam(name="size",defaultValue="0") int page,
@RequestParam(name="page",defaultValue="5") int size) {
return bienRepository.chercher("%"+mc+"%",new PageRequest(page,size));
}
使用
this.http.get('url:http://localhost:8080/searchmc=A').
map(resp=>resp.json()).
subscribe(data=>{this.pageBien=data;},err=>{console.log(err) } );
我遇到了这个问题
无法加载 url:http://localhost:8080/search?mc=A: 跨域请求仅支持协议方案:http、data、chrome、chrome-extension、https。
请给点建议!
【问题讨论】:
-
是否需要url:开头。从错误消息看来,这就是问题所在。只使用
http://....而不使用url: