我現在有這樣的方法:彈簧安置重定向控制器到另一個
@RequestMapping(value = "/{id}/behavior/{behaviorId}", method = RequestMethod.PUT)
private ResponseEntity modifyBehavior(@PathVariable("id") String id, @PathVariable("behaviorId") String behaviorId, @RequestBody BehaviorDto behaviorDto) {
if (aptitudeRepository.findById(id) == null) {
return new ResponseEntity(HttpStatus.BAD_REQUEST);
}
if (aptitudeRepository.findBehaviorById(id, behaviorId) == null) {
return new ResponseEntity(HttpStatus.NOT_FOUND);
} Behavior behavior = new Behavior(behaviorId,behaviorDto.getEn(),behaviorDto.getEs());
return new ResponseEntity(aptitudeRepository.updateBehaviorById(id, behavior), HttpStatus.ACCEPTED);
即時處理的,因爲我喜歡這種方法的要求,但我的同事告訴我,這個方法(和其他行爲的方法應在 自己BehaviorController類。我搬到搬運到另一個類(BehaviorController)爲行爲的方法和所有的工作相當的espected。第一個方法/aptitude
和/aptitude/{id}
被重定向到aptitudeController和其他方法,如/aptitude/{id}/behavior
和aptitude/{id}/behavior/id
已成功重定向到BehaviorController,一切都很好。
buuuuut現在有人告訴我,這個方法應該從AptitudeController被重定向到BehaviorController。他們@PathVariables並一起返回其他方法回報(XD遺憾的英語不好)
所以它最終是這樣的:
@RequestMapping(value = "/{id}/behavior/{behaviorId}", method = RequestMethod.PUT)
private ResponseEntity modifyBehavior(@PathVariable("id") String id,
@PathVariable("behaviorId") String behaviorId,
@RequestBody BehaviorDto behaviorDto) {
return *somehowMethodRedirecting*?
任何人都可以點我在正確的方向?
im kinda newb,你能解釋一下你的意思嗎?「從行爲控制器的AptitudeController創建一個bean」?對不起xD –
我的意思是BehaviorController的對象 –