错误情况
——后端——
@RestController
@RequestMapping("/content")
public class ContentController {
@Reference
private ContentService contentService;
@RequestMapping("/findByCategoryId")
public List<Content> findByCategoryId(Long categoryId) {
System.out.println("运行findByCategoryId");
return contentService.findByCategoryId(categoryId);
}
}
后端测试没问题,可以正常查询数据库并返回json给前端。
——service.js文件——
service只负责与后端进行异步请求和响应,应该也没问题。(测试这层的方法跟测试后端一样,将这层的测试看成直接地址访问)
//服务层
app.service('contentService',function($http){
//根据广告类型id查询列表
this.findByCategoryId = function (categoryId) {
return $http.get("../content/findByCategoryId.shtml?categoryId=" + categoryId);
};
});
——controlle.js文件——
// //控制层
app.controller('contentController', function ($scope,$controller, contentService) {
$controller('baseController'