我有一个返回类型ActionForward的方法,并且需要在某些情况下返回401响应。如何/我可以从这种方法返回什么来给出所需的结果?
public ActionForward doExecute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
...
if (some sort of error situation){
// need to return a 401 here
}
...
}
response.sendError(HttpServletResponse.SC_UNAUTHORIZED);