struts2初学的问题
//pojo封装
package com.island.struts2.pojo;
public class Seach {
private int empNo;
public int getEmpNo() {
return empNo;
}
public void setEmpNo(int empNo) {
this.empNo = empNo;
}
}
//action
package com.island.struts2.action;
import java.util.List;
import com.island.struts2.pojo.Seach;
import com.island.struts2.use.UseDb;
import com.opensymphony.xwork2.ActionContext;
public class SeachAction {
private String eName;
public String geteName() {
return eName;
}
public void seteName(String eName) {
this.eName = eName;
}
public String execute() throws Exception{
UseDb use=new UseDb();
List<Seach> seachs =use.queryByEName(eName);
ActionContext.getContext().getSession().put("seachs", seachs);
return "success";
}
}
//数据库操作
package com.island.struts2.use;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import
java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import com.island.struts2.pojo.Seach;
public class UseDb {
public List<Seach> queryByEName(String eName){
List<Seach> seachs = new ArrayList<Seach>();
Seach seach=null;
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection conn = DriverManager.getConnection(
"jdbc:oracle:thin:@localhost:1521:orcl", "scott","tiger");
String sql="SELECT * FROM EMP WHERE ENAME LIKE '%?%'";
PreparedStatement pstmt = conn.prepareStatement(sql);
pstmt.setString(1, eName);
ResultSet rs = pstmt.executeQuery();
for(;;){
if(rs.next()) break;
seach = new Seach();
seach.setEmpNo(rs.getInt("empNo"));
seachs.add(seach);
}
} catch (
SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (
ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return seachs;
}
}
//struts2配置文件
<package name="default" extends="struts-default">
<!-- 配置处理客户请求,调用SeachAction -->
<action name="result" class="com.island.struts2.action.SeachAction">
<!-- 定义两个结果,获得取值并返回相应jsp页面 -->
<result name="success">/result.jsp</result>
</action>
</package>
//jsp页面输入,eName返回eName,empNo;
不知道哪里出错了,求帮助
------解决方案--------------------
把报的错误贴出来啊