求JSP动态网页,能实现数据增删改查就行,不需要太复杂。。。 只要数据增删改查代码
2个回答
展开全部
package com.fourflower.bean;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import javax.faces.event.ActionEvent;
import javax.faces.model.DataModel;
import javax.faces.model.ListDataModel;
import com.fourflower.login.LoginBacking;
import com.fourflower.tools.Tool;
/**
*
* @author juyang
*
*/
public class AccoutSettingBean {
private ArrayList<AccoutSetting> asbList;
private String ALterCodeMsg;//结算方式代码提示信息
private boolean codeRender =false;//
private String ALterNameMsg;//结算方式名称提示信息
private boolean nameRender =false;//
private String ALterMsg;//添加成功与否
private boolean enRender =false;//
public String checkuser="";
String user_power ="";
public AccoutSettingBean(){
this.asbList = new ArrayList<AccoutSetting>();
seletASBean();
}
// public int getTotal() {
// int total = 0;
// Connection conn = Tool.getConnection("localhost","sa","sa");
//
// try {
// PreparedStatement pre = conn.prepareStatement("select count(*) as num from TDZ_JSMODE");
//
// ResultSet rs = pre.executeQuery();
//
// if(rs.next()){
// total = rs.getInt(1);
// }
// } catch (SQLException e) {
//
// e.printStackTrace();
// }finally{
//
// }
//
// return total;
// }
/**
* 查询所有记录
* @return
*/
public ArrayList<AccoutSetting> seletASBean(){
ArrayList<AccoutSetting> aList = new ArrayList<AccoutSetting>();
Connection con = null;
PreparedStatement ps = null;
ResultSet rs = null;
con = Tool.getConnect("HDZSYSDB","sa","sa");//
try {
ps = con.prepareStatement("select * from TDZ_JSMODE");
rs = ps.executeQuery();
while(rs.next()){
AccoutSetting asbean = new AccoutSetting();
asbean.setSettleWayCode(rs.getString("MODECODE"));
asbean.setSettleWayName(rs.getString("MODENAME"));
aList.add(asbean);
}
} catch (SQLException e) {
e.printStackTrace();
}
finally{
try{
if(ps != null){
ps.close();
}
if(con !=null){
con.close();
}
}
catch (SQLException e){
e.printStackTrace();
}
}
this.asbList = aList;
return aList;
}
/**
*
* 删除某条记录
* @return
*/
public String deleteItem(){
user_power = LoginBacking.userPower;
if("普通用户".equals(user_power.trim()))
{
checkuser = "error";
}else{
for(int i=0;i<asbList.size();i++){
if (asbList.get(i).isSelected()) {
this.deleteItem(asbList.get(i).getSettleWayCode());
}
}
checkuser="";
}
return checkuser;
}
public boolean deleteItem(String code){
// String code = "";
// for(int i =0;i<asbList.size();i++){
// if(asbList.get(i).isSelected());{
// System.out.println(i);
// code = asbList.get(i).settleWayCode;
// }
// }
// System.out.println(code);
boolean flag = false;
Connection con = null;
PreparedStatement ps = null;
try {
//
con = Tool.getConnect("HDZSYSDB","sa","sa");
//
ps = con.prepareStatement("delete from TDZ_JSMODE where MODECODE=?");
//
ps.setString(1, code);
//
int i = ps.executeUpdate();
//
if(i == 1) {
flag = true;
// this.asbList = asbList;
this.seletASBean();
}
} catch (SQLException e) {
e.printStackTrace();
}
//
finally{
try {
if(ps != null) {
ps.close();
}
if(con != null) {
con.close();
}
} catch (SQLException e) {
e.printStackTrace();
}
}
//
return flag;
}
public ArrayList<AccoutSetting> getAsbList() {
return asbList;
}
public void setAsbList(ArrayList<AccoutSetting> asbList) {
this.asbList = asbList;
}
public String getALterCodeMsg() {
return ALterCodeMsg;
}
public void setALterCodeMsg(String lterCodeMsg) {
ALterCodeMsg = lterCodeMsg;
}
public boolean isCodeRender() {
return codeRender;
}
public void setCodeRender(boolean codeRender) {
this.codeRender = codeRender;
}
public String getALterNameMsg() {
return ALterNameMsg;
}
public void setALterNameMsg(String lterNameMsg) {
ALterNameMsg = lterNameMsg;
}
public boolean isNameRender() {
return nameRender;
}
public void setNameRender(boolean nameRender) {
this.nameRender = nameRender;
}
public String getALterMsg() {
return ALterMsg;
}
public void setALterMsg(String lterMsg) {
ALterMsg = lterMsg;
}
public boolean isEnRender() {
return enRender;
}
public void setEnRender(boolean enRender) {
this.enRender = enRender;
}
public String getCheckuser() {
return checkuser;
}
public void setCheckuser(String checkuser) {
this.checkuser = checkuser;
}
public String getUser_power() {
return user_power;
}
public void setUser_power(String user_power) {
this.user_power = user_power;
}
}
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import javax.faces.event.ActionEvent;
import javax.faces.model.DataModel;
import javax.faces.model.ListDataModel;
import com.fourflower.login.LoginBacking;
import com.fourflower.tools.Tool;
/**
*
* @author juyang
*
*/
public class AccoutSettingBean {
private ArrayList<AccoutSetting> asbList;
private String ALterCodeMsg;//结算方式代码提示信息
private boolean codeRender =false;//
private String ALterNameMsg;//结算方式名称提示信息
private boolean nameRender =false;//
private String ALterMsg;//添加成功与否
private boolean enRender =false;//
public String checkuser="";
String user_power ="";
public AccoutSettingBean(){
this.asbList = new ArrayList<AccoutSetting>();
seletASBean();
}
// public int getTotal() {
// int total = 0;
// Connection conn = Tool.getConnection("localhost","sa","sa");
//
// try {
// PreparedStatement pre = conn.prepareStatement("select count(*) as num from TDZ_JSMODE");
//
// ResultSet rs = pre.executeQuery();
//
// if(rs.next()){
// total = rs.getInt(1);
// }
// } catch (SQLException e) {
//
// e.printStackTrace();
// }finally{
//
// }
//
// return total;
// }
/**
* 查询所有记录
* @return
*/
public ArrayList<AccoutSetting> seletASBean(){
ArrayList<AccoutSetting> aList = new ArrayList<AccoutSetting>();
Connection con = null;
PreparedStatement ps = null;
ResultSet rs = null;
con = Tool.getConnect("HDZSYSDB","sa","sa");//
try {
ps = con.prepareStatement("select * from TDZ_JSMODE");
rs = ps.executeQuery();
while(rs.next()){
AccoutSetting asbean = new AccoutSetting();
asbean.setSettleWayCode(rs.getString("MODECODE"));
asbean.setSettleWayName(rs.getString("MODENAME"));
aList.add(asbean);
}
} catch (SQLException e) {
e.printStackTrace();
}
finally{
try{
if(ps != null){
ps.close();
}
if(con !=null){
con.close();
}
}
catch (SQLException e){
e.printStackTrace();
}
}
this.asbList = aList;
return aList;
}
/**
*
* 删除某条记录
* @return
*/
public String deleteItem(){
user_power = LoginBacking.userPower;
if("普通用户".equals(user_power.trim()))
{
checkuser = "error";
}else{
for(int i=0;i<asbList.size();i++){
if (asbList.get(i).isSelected()) {
this.deleteItem(asbList.get(i).getSettleWayCode());
}
}
checkuser="";
}
return checkuser;
}
public boolean deleteItem(String code){
// String code = "";
// for(int i =0;i<asbList.size();i++){
// if(asbList.get(i).isSelected());{
// System.out.println(i);
// code = asbList.get(i).settleWayCode;
// }
// }
// System.out.println(code);
boolean flag = false;
Connection con = null;
PreparedStatement ps = null;
try {
//
con = Tool.getConnect("HDZSYSDB","sa","sa");
//
ps = con.prepareStatement("delete from TDZ_JSMODE where MODECODE=?");
//
ps.setString(1, code);
//
int i = ps.executeUpdate();
//
if(i == 1) {
flag = true;
// this.asbList = asbList;
this.seletASBean();
}
} catch (SQLException e) {
e.printStackTrace();
}
//
finally{
try {
if(ps != null) {
ps.close();
}
if(con != null) {
con.close();
}
} catch (SQLException e) {
e.printStackTrace();
}
}
//
return flag;
}
public ArrayList<AccoutSetting> getAsbList() {
return asbList;
}
public void setAsbList(ArrayList<AccoutSetting> asbList) {
this.asbList = asbList;
}
public String getALterCodeMsg() {
return ALterCodeMsg;
}
public void setALterCodeMsg(String lterCodeMsg) {
ALterCodeMsg = lterCodeMsg;
}
public boolean isCodeRender() {
return codeRender;
}
public void setCodeRender(boolean codeRender) {
this.codeRender = codeRender;
}
public String getALterNameMsg() {
return ALterNameMsg;
}
public void setALterNameMsg(String lterNameMsg) {
ALterNameMsg = lterNameMsg;
}
public boolean isNameRender() {
return nameRender;
}
public void setNameRender(boolean nameRender) {
this.nameRender = nameRender;
}
public String getALterMsg() {
return ALterMsg;
}
public void setALterMsg(String lterMsg) {
ALterMsg = lterMsg;
}
public boolean isEnRender() {
return enRender;
}
public void setEnRender(boolean enRender) {
this.enRender = enRender;
}
public String getCheckuser() {
return checkuser;
}
public void setCheckuser(String checkuser) {
this.checkuser = checkuser;
}
public String getUser_power() {
return user_power;
}
public void setUser_power(String user_power) {
this.user_power = user_power;
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2011-03-01
展开全部
我有个程序是用sturst2.0做的行吗?可以增删改查,还有分页。。。。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询