📄 复件 nodeaction.java
字号:
package product.action;
import product.db.*;
import product.form.*;
import java.sql.*;
import java.util.*;
import javax.servlet.http.*;
import org.apache.struts.action.*;
import org.apache.struts.actions.DispatchAction;
public class NodeAction extends DispatchAction{
public ActionForward listNext(ActionMapping mapping,ActionForm form,
HttpServletRequest request,HttpServletResponse response)
throws Exception
{
String target = "list";
PageForm pageBean = (PageForm)form;
String id=request.getParameter("id");
if(id==null)id="0";
String name=request.getParameter("name");
if(name!=null)
name=new String(name.getBytes("iso-8859-1"),"gb2312");
int layer=Integer.parseInt(request.getParameter("layer"));
//String t="--><a href='/hualong/node.do?method=listNext&id="+id+"&name="+name+"&layer="+layer;
HttpSession session = request.getSession();
if(layer==0){
session.setAttribute("layer","0");
}
if(layer==1){
session.setAttribute("layer1id",id);
session.setAttribute("layer1name",name);
session.setAttribute("layer","1");
}
if(layer==2){
session.setAttribute("layer2id",id);
session.setAttribute("layer2name",name);
session.setAttribute("layer","2");
}
if(layer==3){
session.setAttribute("layer3id",id);
session.setAttribute("layer3name",name);
session.setAttribute("layer","3");
}
if(layer==4){
session.setAttribute("layer4id",id);
session.setAttribute("layer4name",name);
session.setAttribute("layer","4");
}
if(layer==5){
session.setAttribute("layer5id",id);
session.setAttribute("layer5name",name);
session.setAttribute("layer","5");
}
Connection con = null;
try{
con=DatabaseConnection.getConnection();
Statement st = con.createStatement();
String q1 = "SELECT COUNT(*) AS total FROM Product WHERE parent="+id;
ResultSet rs1 = st.executeQuery(q1);
int total = 0;
if(rs1.next()){
total = rs1.getInt("total");
}
pageBean.setMaxRowCount(total);
pageBean.setMaxPage();
int num = pageBean.getRowsPerPage();
int start = (pageBean.getCurPage()-1)*num;
String q2="SELECT * FROM Product where parent="+id+" ORDER BY id ASC LIMIT "+start+","+num;
System.out.println("q2==="+q2);
ResultSet rs2 = st.executeQuery(q2);
Vector v = new Vector();
Node node = new Node();
int startId=0;
NodeDAO nodeDAO = new NodeDAO();
if(rs2.next()){
node.setId(rs2.getInt("id"));
node.setNextId(rs2.getInt("nextId"));
node.setName(rs2.getString("name"));
node.setParent(rs2.getInt("parent"));
node.setSize(rs2.getString("size"));
node.setUnit(rs2.getString("unit"));
node.setContent(rs2.getString("content"));
node.setProduct_factory(rs2.getString("product_factory"));
node.setProduct_supply(rs2.getString("product_supply"));
node.setColor(rs2.getString("color"));
node.setPrice_in(rs2.getFloat("price_in"));
node.setPrice_sale(rs2.getFloat("price_sale"));
node.setPrice_detail(rs2.getFloat("price_detail"));
node.setSpecification(rs2.getString("specification"));
node.setNote(rs2.getString("note"));
node.setCreateDay(rs2.getDate("createDay"));
node.setLayer(rs2.getInt("layer"));
node.setNextId(rs2.getInt("nextId"));
System.out.println("price=="+rs2.getFloat("price_detail"));
v.add(node);
}
while(rs2.next()){
node = nodeDAO.getNode(node.getNextId());
v.add(node);
}
pageBean.setData(v);
}catch(Exception e){
e.printStackTrace();
throw e;
}finally{
try{
if(con!=null){
con.close();
}
}catch(Exception e2){}
}
return mapping.findForward(target);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -