日期:2014-05-17  浏览次数:20689 次

菜鸟紧急求助 初学struts 找不出错误
struts-config.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://struts.apache.org/dtds/struts-config_1_2.dtd">

<struts-config>
  <data-sources />
  <form-beans >
  <form-bean name="loginForm" type="com.pdsu.cbx.LoginForm "></form-bean>
  </form-beans>

  <action-mappings >
  <action path="/login" type="com.pdsu.cbx.LoginAction" name="loginForm">
  <forward name="loginSucess" path="/welcome.jsp"></forward>
  <forward name="loginFailure" path="/login.jsp"></forward>
  </action>
  </action-mappings>
  <message-resources parameter="com.yourcompany.struts.ApplicationResources" />
</struts-config>
LoginAction.java
package com.pdsu.cbx;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

public class LoginAction extends Action {

public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {


LoginForm loginForm=(LoginForm) form;


if(loginForm.getUsername().equals("admin")&&loginForm.getPassword().equals("123")){
return mapping.findForward("loginSucess");
}
else{
return mapping.findForward("loginFailure");
}


}

}
LoginForm.java

package com.pdsu.cbx;

import org.apache.struts.action.ActionForm;

public class LoginForm extends ActionForm {
private String username;
private String password;
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;
}

}
login.jsp

<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<html>
  <head>
   
   
  <title>My JSP 'login.jsp' starting page</title>

  </head>
  
  <body>
  <form action="login.do" method="post">
  username:<input type="text" name="username" ><br>
  password:<input type="password" name="password"/><br>
  <input type="submit" value="login"/>
  </form>
  </body>
</html>
错误提示

HTTP Status 500 - 

--------------------------------------------

type Exception report

message 

description The server encountered an internal error () that prevented it from fulfilling this req