如何通过 Struts return 401 错误响应?

How to return a 401 error response via Struts?

我有一个 return 类型 ActionForward 的方法,在某些情况下需要 return 401 响应。 How/what 我可以 return 从这个方法得到想要的结果吗?

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);