struts转发问题
struts开发中通过Action处理以后总是不能在struts-config.xml中找到转发地址,而是报错org.apache.struts.action.RequestProcessor
★★★★★★★★★★★★★★enterAddUserAction.java★★★★★★★★★★★★★
package action;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.sql.DataSource;
import org.apache.struts.action.Action;
import org.apache.struts.action.
ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
public class enterAddUserAction extends Action{
public ActionForward execute(ActionMapping arg0, ActionForm arg1,
HttpServletRequest request, HttpServletResponse reponse) throws Exception {
ActionErrors errors=new ActionErrors();
//------构造查询的SQL语句------
String sqlStr1="select count(*) as recordCount1 from Department";
String sqlStr2="select * from Department";
String sqlStr3="select count(*) as recordCount2 from [Role]";
String sqlStr4="select * from [Role]";
//------查询出数据,将查询结果数据集写入到request中------
try{
String url="jdbc:sqlserver://localhost:1433;DatabaseName=test";
String userName="sa";
String password="123";
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection conn = DriverManager.getConnection(url,userName,password);
//------查询数据------
//------装载部门数据------
Statement sql1=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
ResultSet rs1=sql1.executeQuery(sqlStr1);
if(rs1.next()){
Object[][] rsArray1=new Object[rs1.getInt("recordCount1")][2];
Statement sql2=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
ResultSet rs2=sql2.executeQuery(sqlStr2);
int i=0;
while(rs2.next()){
rsArray1[i][0]=rs2.getString("DepartID");
rsArray1[i][1]=rs2.getString("DepartName");
i++;
}
request.setAttribute("rsArray1",rsArray1);
}
//------装载角色数据------
Statement sql3=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
ResultSet rs3=sql3.executeQuery(sqlStr3);
if(rs3.next()){
Object[][] rsArray2=new Object[rs3.getInt("recordCount2")][2];
Statement sql4=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
ResultSet rs4=sql4.executeQuery(sqlStr4);
int i=0;
while(rs4.next()){
rsArray2[i][0]=rs4.getString("RoleID");
rsArray2[i][1]=rs4.getString("RoleName");
i++;
}
request.setAttribute("rsArray2",rsArray2);
}
//------关闭数据库连接------
if(conn!=null)
conn.close();
}catch(Exception e){
e.printStackTrace();
errors.add("DBOPError",new ActionMessage("DBOPError"));
saveErrors(request,errors);
}
return
arg0.findForward("enterAddUserJSP"); }
}
以下是相关XML文件的部分截取
★★★★★★★★★★★★★★struts-config.xml★★★★★★★★★★★★★
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-con