我的控制器中有两种方法:
它们都有@requestMapping并且都引用了一个全局变量(@autowrite)。问题是第一个方法变量有值,而第二个方法变量为空。
请帮我。
/**
* Both of these methods are accessible through the browser,
* when i ask for query1 the flowService has value but
* when i ask for query2 the flowService is null.
* My spring version is 4.2.4
* Created by hanxiaofei on 2017/10/12.
*/
public class TestController {
@Autowired
private FlowService flowService;
@RequestMapping(value = {"/query1"})
@ResponseBody
public CommonListResult<WorkOrderMO> query1() {
return flowService.queryWorkOrderList(1);
}
@RequestMapping(value = {"/query2"})
@ResponseBody
private CommonListResult<WorkOrderMO> query2() {
return flowService.queryWorkOrderList(1);
}
}
Run Code Online (Sandbox Code Playgroud)
带有注释的控制器方法@RequestMappings必须是公共的才能正常工作。无论如何,没有理由将请求方法设置为私有,因为无论如何您都不应该自己从不同的组件调用控制器方法。
| 归档时间: |
|
| 查看次数: |
3285 次 |
| 最近记录: |