1

我有一个为 /session_auth_uri 配置了会话身份验证的控制器,如下所示:

@Controller
@RequestMapping("/session_auth_uri")
public class BaseController {

  @RequestMapping(value = "/do", method = RequestMethod.POST, consumes =    "application/json", produces = "application/json")
  @ResponseBody
  public Result do(@RequestBody Query query) throws SomeException {
    return new Result();
  }

  @RequestMapping(value = "/exec", method = RequestMethod.POST, consumes =    "application/json", produces = "application/json")
  @ResponseBody
  public Result exec(@RequestBody Query query) throws SomeException {
    return new Result();
  }
}

我想扩展 BaseController 以重用 1 个处理程序方法 => do(...) (基本身份验证用于 /basic_auth_uri):

@Controller
@RequestMapping("/basic_auth_uri")
public class SubclassController extends BaseController {
}

问题是我希望在访问/basic_auth_uri/exec 时为 exec(...) 处理程序方法返回 HttpStatus.NOT_IMPLEMENTED。

感谢您的任何建议。

4

1 回答 1

1

除了在 SubclassController 中覆盖它之外,想不出任何其他方法:

@Controller
@RequestMapping("/basic_auth_uri")
public class SubclassController extends BaseController {
  @RequestMapping(value = "/exec", method = RequestMethod.POST, consumes =    "application/json", produces = "application/json")
  @ResponseStatus(HttpStatus.NOT_IMPLEMENTED)
  public Result exec(@RequestBody Query query) throws SomeException {
    return null;
  }

}
于 2012-10-03T20:04:54.497 回答