求助:
Cannot forward after response has been committedlogin_Faild.jsp:
<%@ page contentType= "text/html;charset=gb2312 "%>
<%@ taglib uri= "/tags/struts-html " prefix= "html " %>
<html>
<head>
<title> </title>
<meta http-equiv= "Refresh " content= "3;url=/web/login.html ">
</head>
<body>
<b> <html:errors/> </b> <br/>
</body>
</html>
-------------------------------------------
UserAction.java:
public ActionForward login(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
{
String username = request.getParameter( "username ");
String pwd = request.getParameter( "password ");
ActionErrors errors = new ActionErrors();
String target = "index ";
if(username == null || username.trim().length() ==0 ||
pwd == null || pwd.trim().length() == 0)
{
errors.add(ActionErrors.GLOBAL_ERROR, new ActionError( "Username and password can not blank. "));
target = "loginFailed ";
}
else
{
User user = new User();
user.setPwd(pwd);
user.setUsername(username);
UserService service = new UserService();
try
{
service.login(user);
HttpSession session = request.getSession(true);
session.setAttribute( "UserSession ", user);
}
catch(AuthenticationException ex)
{
errors.add(ActionErrors.GLOBAL_ERROR, new ActionError( "Username or password is invalid. "));
target = "loginFailed ";
}
}
if(!errors.isEmpty())
saveErrors(request, errors);
return mapping.findForward(target);
}
---------------------
struts-config.xml
<action
parameter= "method "
path= "/userAction "
scope= "request "
type= "com.cogentsystems.ib.presentation.action.UserAction ">
<forward name= "loginpage " path= "/login.html " />
<forward name= "index " path= "/index_page.html " />
<forward name= "loginFailed " path= "/login_Failed.jsp " />
</action>
现在登陆页一提交就抱错:
java.lang.IllegalStateException: Cannot forward after response has been committed
我使用的是TOMCAT 5.0