刚刚开始学习Struts,遇到一个问题,index.jsp点击提交按钮的时候地址栏里显示
http://localhost:8080/mystruts/register.do;jsessionid=3FA77C83EA8BCCCECCF2B522E1A30EB8 
画面并没有任何显示信息,也就是说没有转到success.jsp或者failure.jsp,请问错误是出在什么地方?
struts-config.xml配置的<form-beans>和<action-mappings>信息如下:
//-------------------------start----------------------------------
<form-beans>
<form-bean
name="RegisterForm"
type="actionform.RegisterForm">
</form-bean>
</form-beans>
<action-mappings>
<action
path="/register"
type="action.RegisterAction"
name="RegisterForm"
scope="request"
input="/index.jsp">
<forward
name="success"
path="/success.jsp"/>
<forward
name="failure"
path="/failure.jsp"/>
</action>
</action-mappings>
//------------------------end--------------------------------------

RegisterAction.java文件内容:
//------------------------start--------------------------------------
package action;import java.io.IOException;
import javax.servlet.http.*;
import actionform.RegisterForm;
import org.apache.struts.action.*;
import javax.servlet.ServletException;public class RegisterAction extends Action {

public ActionForward excute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest req,
HttpServletResponse res) throws IOException, ServletException {
 
RegisterForm rf = (RegisterForm) form;
String username = rf.getUsername();
String password = rf.getPassword();
String repassword = rf.getRepassword();

if (isNullOrEmpty(username)) {
return mapping.findForward("failure");
}

if (isNullOrEmpty(password)) {
return mapping.findForward("failure");
}

if(isNullOrEmpty(repassword)){
return mapping.findForward("failure");
}

return mapping.findForward("success");
}

private boolean isNullOrEmpty(String string){

return string == null || string.trim().length() == 0;

}
}
//------------------------end---------------------------------------
RegisterForm.java文件内容:
//----------------------------start-------------------------------
package actionform;import javax.servlet.http.*;
import org.apache.struts.action.ActionForm;public class RegisterForm extends ActionForm {

private String username;
private String password;
private String repassword;

public String getUsername() {
return username;
}

public void setUsername(String username) {
this.username = username;
}

public String getPassword() {
return password;
}

public void setPassword(String password) {
this.password = password;
}

public String getRepassword() {
return repassword;
}

public void setRepassword(String repassword) {
this.repassword = repassword;
}
}
//------------------------end-------------------------------------

解决方案 »

  1.   

    jsessionid=3FA77C83EA8BCCCECCF2B522E1A30EB8
    这个东东是什么
    为什么会自动出现它
    我不明白啊~
      

  2.   

    看上去没什么错啊!为什么地址拦会出现jsessionid=3FA77C83EA8BCCCECCF2B522E1A30EB8 ?
      

  3.   

    jsessionid是正常的,是Tomcat识别Session用的一个方法而已。
    你需要打一下log或者debug,首先看程序有没有执行你的Action
      

  4.   

    if (isNullOrEmpty(username)) {
    return mapping.findForward("failure");
    }if (isNullOrEmpty(password)) {
    return mapping.findForward("failure");
    }if(isNullOrEmpty(repassword)){
    return mapping.findForward("failure");
    }return mapping.findForward("success");
    }private boolean isNullOrEmpty(String string){return string == null || string.trim().length() == 0;
      

  5.   

    jsessionid是正常的,常碰到的
    界面没有任何信息是,空白的么,还是index.jsp界面没有提交呢.
    到action里去看看,有没有执行到.
      

  6.   

    同样是新手,也遇到过这种问题,好像当时是action的问题