用的是MVC 的方式写的代码:  M代码为:
package xxx.shop.ub;import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;public class odeBC {
private ResultSet rs=null;
private Connection conn=null;
private PreparedStatement pstmt  =null;


public boolean add(mycarUBC mubc,String id){
boolean b=true;
try {
conn=new ConnDB().getConnection();
System.out.println("查看运行结果如下:");
System.out.println("id="+id);
System.out.println("mubc.returnallprice()="+mubc.returnallprice());
pstmt=conn.prepareStatement("insert into ode (uId,isPayed,totalPrice) values (?,?,?)");
pstmt.setString(1,id);
pstmt.setByte(2, (byte)0);
pstmt.setFloat(3, mubc.returnallprice());
int a= pstmt.executeUpdate();
if(a==1){
pstmt=conn.prepareStatement("select max(oId) from ode");
rs=pstmt.executeQuery();
int oid=0;
if(rs.next()){
oid=rs.getInt(1);
}
ArrayList aList =mubc.showmycar();
System.out.println("oid="+oid);

Statement sm=conn.createStatement();
for(int i=0;i<aList.size();i++){
shopUB sub=(shopUB)aList.get(i);
System.out.println("sub.getGoodsId()="+sub.getGoodsId());
System.out.println("mubc.getgoodsnumbyid(sub.getGoodsId())="+mubc.getgoodsnumbyid(sub.getGoodsId()+""));
String sql="insert into odeD values('"+oid+"','"+sub.getGoodsId()+"','"+mubc.getgoodsnumbyid(sub.getGoodsId()+"")+"')";
sm.addBatch(sql);
b=true;
}
sm.executeBatch();
}else{
b=false;
}

} catch (Exception e) {
b=false;
e.printStackTrace();
// TODO: handle exception
}finally{
this.close();
}
return b=false;
}



public void close(){
try {

if(rs!=null){
rs.close();
rs=null;

}
if(pstmt!=null){
pstmt.close();
pstmt=null;
}
if(conn!=null){
conn.close();
conn=null;
}

} catch (Exception e) {
e.printStackTrace();
// TODO: handle exception
}
}}
servlet代码如下: public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException { response.setContentType("text/html");
response.setCharacterEncoding("utf-8");
PrintWriter out = response.getWriter();
odeBC odb=new odeBC();
mycarUBC mubc=(mycarUBC)request.getSession().getAttribute("mycar");
long id=((UB)request.getSession().getAttribute("userinfo")).getID();
if(odb.add(mubc, id+"")){
request.getRequestDispatcher("shoporder.jsp").forward(request, response);
}else{
System.out.print("sssdsdsds");
request.getRequestDispatcher("shopcl.jsp").forward(request, response);
}
}
                        后台结果为:       查看运行结果如下:
id=1
mubc.returnallprice()=200.0
oid=28
sub.getGoodsId()=1
mubc.getgoodsnumbyid(sub.getGoodsId())=1
sssdsdsds
问题是 不能正常跳转 只跳向shopcl.jsp   我已经查实 数据库已添加成功!!!!!!但不知道为什么 还是不能正确跳转到shoporder.jsp 望有人解决!!!!!!!!!!!!!!!