struts表单提交(4)和(3)相关
实体类
public class Supplier {
private int id;
private String supplierid;
private String suppliernane;
private String description;
private String phone;
private String address;
private Date starttine;
private String company;
private int remark;
getset方法
}
数据库
dao
public interface SupplierDao {
//查询,供应商列表只显示正在合作的供应商
public List<Supplier> list();
//添加,添加时,不允许显现的添加供应商编号(不允许手动添加)
/*
* Remark字段:用于表示该供应商是否正在合作
* 0:表示暂时中止合作
* 1:表示正在合作
* 注意:添加供应商时,默认remark值为1,即正在合作,
* 对remark的处理方式:
* 1》在dao类里赋值时,写死值为1
* 2》在数据库表中,将remark列设置一下默认值为1
* */
public void supAdd(Supplier supplier);
/*删除时,进行逻辑删除(根据主键将该条数据不再显示在列表)
物理删除:真正从数据库表中删除掉数据,即表中不存在这条数据了
逻辑删除:并不真正从数据库表删掉数据,而是换一种方式显示
执行逻辑删除之后,即暂时中止和某供应商合作,那么供应商列表不再显示该条数据,
执行逻辑删除就是将remark的值由1变为0,其实就是修改remark字段的功能
*/
public Supplier supdelete(int id);
//修改回显
//修改时,不允许修改供应商编号
public Supplier suptoupdate(Supplier supplier);
//修改
public void supddupdate(Supplier supplier);
//重新合作查询
public List<Supplier> newlist();
//重新合作
public Supplier newsupplier(Supplier supplier);
//物理删除彻底删除
public Supplier newdelete(int id);
//正在合作供应商模糊查询
public List<Supplier> supplierslike(Supplier supplier);
//解除合作供应商模糊查询
public List<Supplier> lodsupplierslike(Supplier supplier);
}
daoImpl
public class SupplieDaoImpl implements SupplierDao {
private Connection connection=null;
private PreparedStatement p = null;
private ResultSet set = null;
public Connection getConnection() {
return connection;
}
public void setConnection(Connection connection) {
this.connection = connection;
}
public PreparedStatement getP() {
return p;
}
public void setP(PreparedStatement p) {
this.p = p;
}
public ResultSet getSet() {
return set;
}
public void setSet(ResultSet set) {
this.set = set;
}
/* 供应商列表只显示正在合作的供应商
即查询列表时,执行的是select * from t_supplier where remark=1
*/
@Override
public List<Supplier> list() {
// TODO Auto-generated method stub
try {
connection = DBUtil.getConnection();
String sqlString = "select starttine,address,company,description,id,phone,remark,supplierid,suppliernane from T_SUPPLIER where remark = 1";
p = connection.prepareStatement(sqlString);
set = p.executeQuery();
List<Supplier> list = new ArrayList<Supplier>();
while(set.next()){
Supplier s = new Supplier();
s.setStarttine(set.getDate("starttine"));
s.setAddress(set.getString("address"));
s.setCompany(set.getString("company"));
s.setDescription(set.getString("description"));
s.setId(set.getInt("id"));
s.setPhone(set.getString("phone"));
s.setRemark(set.getInt("remark"));
s.setSupplierid(set.getString("supplierid"));
s.setSuppliernane(set.getString("suppliernane"));
list.add(s);
}
return list;
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
@Override
public void supAdd(Supplier supplier) {
// TODO Auto-generated method stub
try {
connection = DBUtil.getConnection();
String sql = "insert into t_supplier(id,supplierid,suppliernane,description,phone,address,starttine,company,remark) values(t_supplier_id.nextval,?,?,?,?,?,sysdate,?,1)";
p = connection.prepareStatement(sql);
p.setString(1, UUIDUtil.getUUID());
p.setString(2, supplier.getSuppliernane());
p.setString(3, supplier.getDescription());
p.setString(4, supplier.getPhone());
p.setString(5, supplier.getAddress());
p.setString(6, supplier.getCompany());
p.execute();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@Override
public Supplier supdelete(int id) {
// TODO Auto-generated method stub
try {
connection = DBUtil.getConnection();
String sql = "update t_supplier set remark=0 where id=?";
p = connection.prepareStatement(sql);
p.setInt(1, id);
p.execute();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
@Override
public Supplier suptoupdate(Supplier supplier) {
// TODO Auto-generated method stub
try {
connection = DBUtil.getConnection();
String sql = "select * from T_SUPPLIER where id=?";
p = connection.prepareStatement(sql);
p.setInt(1, supplier.getId());
set = p.executeQuery();
Supplier su = new Supplier();//实体
while(set.next()){
su.setStarttine(set.getDate("starttine"));
su.setAddress(set.getString("address"));
su.setCompany(set.getString("company"));
su.setDescription(set.getString("description"));
su.setId(set.getInt("id"));
su.setPhone(set.getString("phone"));
su.setRemark(set.getInt("remark"));
su.setSupplierid(set.getString("supplierid"));
su.setSuppliernane(set.getString("suppliernane"));
}
return su;
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
@Override
public void supddupdate(Supplier supplier) {
// TODO Auto-generated method stub
try {
connection = DBUtil.getConnection();
String sql = "update t_supplier set suppliernane=?,description=?,phone=?,address=?,company=? where id=?";
p = connection.prepareStatement(sql);
p.setString(1, supplier.getSuppliernane());
p.setString(2, supplier.getDescription());
p.setString(3, supplier.getPhone());
p.setString(4, supplier.getAddress());
p.setString(5, supplier.getCompany());
p.setInt(6, supplier.getId());
System.out.println("-----p:"+p.toString());
p.execute();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@Override
public List<Supplier> newlist() {
// TODO Auto-generated method stub
try {
connection = DBUtil.getConnection();
String sql = "select starttine,address,company,description,id,phone,remark,supplierid,suppliernane from T_SUPPLIER where remark = 0";
p = connection.prepareStatement(sql);
set = p.executeQuery();
List<Supplier> newlist = new ArrayList<Supplier>();
while(set.next()){
Supplier supplier = new Supplier();
supplier.setStarttine(set.getDate("starttine"));
supplier.setAddress(set.getString("address"));
supplier.setCompany(set.getString("company"));
supplier.setDescription(set.getString("description"));
supplier.setId(set.getInt("id"));
supplier.setPhone(set.getString("phone"));
supplier.setRemark(set.getInt("remark"));
supplier.setSupplierid(set.getString("supplierid"));
supplier.setSuppliernane(set.getString("suppliernane"));
newlist.add(supplier);
}
return newlist;
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
@Override
public Supplier newsupplier(Supplier supplier) {
// TODO Auto-generated method stub
try {
connection = DBUtil.getConnection();
String sql = "update t_supplier set remark=1 where id=?";
p = connection.prepareStatement(sql);
p.setInt(1, supplier.getId());
p.execute();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
@Override
public Supplier newdelete(int id) {
// TODO Auto-generated method stub
try {
connection = DBUtil.getConnection();
String sql = "delete from t_supplier where id=?";
p = connection.prepareStatement(sql);
p.setInt(1, id);
p.execute();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
//正在合作供应商模糊查询
@Override
public List<Supplier> supplierslike(Supplier supplier) {
// TODO Auto-generated method stub
try {
connection = DBUtil.getConnection();
String sql = "select * from T_SUPPLIER where SUPPLIERNANE like '%"+supplier.getSuppliernane()+"%'"
+ "and DESCRIPTION like '%"+supplier.getDescription()+"%' and REMARK = 1";
p = connection.prepareStatement(sql);
List<Supplier> list = new ArrayList<>();
set = p.executeQuery();
while(set.next()){
Supplier supplie1 = new Supplier();
supplie1.setStarttine(set.getDate("starttine"));
supplie1.setAddress(set.getString("address"));
supplie1.setCompany(set.getString("company"));
supplie1.setDescription(set.getString("description"));
supplie1.setId(set.getInt("id"));
supplie1.setPhone(set.getString("phone"));
supplie1.setRemark(set.getInt("remark"));
supplie1.setSupplierid(set.getString("supplierid"));
supplie1.setSuppliernane(set.getString("suppliernane"));
list.add(supplie1);
}
return list;
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
//解除合作供应商模糊查询
@Override
public List<Supplier> lodsupplierslike(Supplier supplier) {
// TODO Auto-generated method stub
try {
connection = DBUtil.getConnection();
String sql = "select * from T_SUPPLIER where SUPPLIERNANE like '%"+supplier.getSuppliernane()+"%'"
+ "and DESCRIPTION like '%"+supplier.getDescription()+"%' and REMARK = 0";
p = connection.prepareStatement(sql);
List<Supplier> list = new ArrayList<>();
set = p.executeQuery();
while(set.next()){
Supplier supplie1 = new Supplier();
supplie1.setStarttine(set.getDate("starttine"));
supplie1.setAddress(set.getString("address"));
supplie1.setCompany(set.getString("company"));
supplie1.setDescription(set.getString("description"));
supplie1.setId(set.getInt("id"));
supplie1.setPhone(set.getString("phone"));
supplie1.setRemark(set.getInt("remark"));
supplie1.setSupplierid(set.getString("supplierid"));
supplie1.setSuppliernane(set.getString("suppliernane"));
list.add(supplie1);
}
return list;
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
}
service
public interface SupplierServlice {
public List<Supplier> list();
public void supAdd(Supplier supplier);
public Supplier supdelete(int id);
//修改页面
public Supplier supplier(Supplier supplier);
public void supddupdate(Supplier supplier);
//重新合作查询
public List<Supplier> newlist();
//重新合作
public Supplier newsupplier(Supplier supplier);
//彻底结束合作
public Supplier newdelete(int id);
//正在合作供应商模糊查询
public List<Supplier> supplierslike(Supplier supplier);
//解除合作供应商模糊查询
public List<Supplier> lodsupplierslike(Supplier supplier);
}
serviceImpl
public class SupplierServiceImpl implements SupplierServlice {
private SupplierDao s = new SupplieDaoImpl();
@Override
public List<Supplier> list() {
// TODO Auto-generated method stub
return s.list();
}
public SupplierDao getS() {
return s;
}
public void setS(SupplierDao s) {
this.s = s;
}
@Override
public void supAdd(Supplier supplier) {
// TODO Auto-generated method stub
s.supAdd(supplier);
}
@Override
public Supplier supdelete(int id) {
// TODO Auto-generated method stub
return s.supdelete(id);
}
@Override
public Supplier supplier(Supplier supplier) {
// TODO Auto-generated method stub
return s.suptoupdate(supplier);
}
@Override
public void supddupdate(Supplier supplier) {
// TODO Auto-generated method stub
s.supddupdate(supplier);
}
@Override
public List<Supplier> newlist() {
// TODO Auto-generated method stub
return s.newlist();
}
@Override
public Supplier newsupplier(Supplier supplier) {
// TODO Auto-generated method stub
return s.newsupplier(supplier);
}
@Override
public Supplier newdelete(int id) {
// TODO Auto-generated method stub
return s.newdelete(id);
}
//正在合作供应商模糊查询
@Override
public List<Supplier> supplierslike(Supplier supplier) {
// TODO Auto-generated method stub
return s.supplierslike(supplier);
}
//解除合作供应商模糊查询
@Override
public List<Supplier> lodsupplierslike(Supplier supplier) {
// TODO Auto-generated method stub
return s.lodsupplierslike(supplier);
}
}
action
public class SupplierAction extends ActionSupport {
private List<Supplier> supplierlist;
private List<Supplier> newsuppList;
private Supplier supplier;
private SupplierServlice supServlice = new SupplierServiceImpl();
public List<Supplier> getSupplierlist() {
return supplierlist;
}
public void setSupplierlist(List<Supplier> supplierlist) {
this.supplierlist = supplierlist;
}
public SupplierServlice getSupServlice() {
return supServlice;
}
public void setSupServlice(SupplierServlice supServlice) {
this.supServlice = supServlice;
}
//重新合作查询
public String newsuppList(){
supplierlist = supServlice.newlist();
return SUCCESS;
}
//重新合作
public String newsupplier(){
supServlice.newsupplier(supplier);
return SUCCESS;
}
//解除合作
public String newdelete(){
supServlice.newdelete(supplier.getId());
return SUCCESS;
}
public String suplist(){
supplierlist = supServlice.list();
return SUCCESS;
}
public String supAdd(){
supServlice.supAdd(supplier);
/*System.out.println("lalala啦啦......");*/
return SUCCESS;
}
public String supdelete(){
supServlice.supdelete(supplier.getId());
return SUCCESS;
}
public String supupdate(){
supplier = supServlice.supplier(supplier);
return SUCCESS;
}
public String supddupdate(){
supServlice.supddupdate(supplier);
System.out.println("supplier-----:"+supplier);
return SUCCESS;
}
//正在合作供应商模糊查询
public String supplierslike(){
ActionContext ac = ActionContext.getContext();
Map<String, Object> session = ac.getSession();
session.put("name", supplier.getSuppliernane());
session.put("desc", supplier.getDescription());
supplierlist = supServlice.supplierslike(supplier);
return SUCCESS;
}
//解除合作供应商模糊查询
public String lodsupplierslike(){
ActionContext ac = ActionContext.getContext();
Map<String, Object> session = ac.getSession();
session.put("name", supplier.getSuppliernane());
session.put("desc", supplier.getDescription());
supplierlist = supServlice.lodsupplierslike(supplier);
return SUCCESS;
}
public Supplier getSupplier() {
return supplier;
}
public void setSupplier(Supplier supplier) {
this.supplier = supplier;
}
public List<Supplier> getNewsuppList() {
return newsuppList;
}
public void setNewsuppList(List<Supplier> newsuppList) {
this.newsuppList = newsuppList;
}
}
struts.xml
<action name="sup_list" class="com.oak.action.SupplierAction" method="suplist">
<result name="success">
/providerAdmin.jsp
</result>
</action>
<action name="supadd" class="com.oak.action.SupplierAction" method="supAdd">
<result name="success" type="redirectAction">
sup_list
</result>
</action>
<action name="supdelete" class="com.oak.action.SupplierAction" method="supdelete">
<result name="success" type="redirectAction">
sup_list
</result>
</action>
<action name="supupdate" class="com.oak.action.SupplierAction" method="supupdate">
<result name="success">
/providerupdate.jsp
</result>
</action>
<action name="supddupdate" class="com.oak.action.SupplierAction" method="supddupdate">
<result name="success" type="redirectAction">
sup_list
</result>
</action>
<!-- 重新合作查询 -->
<action name="newproviderAdd" class="com.oak.action.SupplierAction" method="newsuppList">
<result name="success">
/newproviderAdmin.jsp
</result>
</action>
<!-- 正在合作供应商模糊查询 -->
<action name="supplierslike" class="com.oak.action.SupplierAction" method="supplierslike">
<result name="success">
/providerAdmin.jsp
</result>
</action>
<!-- 解除合作供应商模糊查询 -->
<action name="lodsupplierslike" class="com.oak.action.SupplierAction" method="lodsupplierslike">
<result name="success">
/newproviderAdmin.jsp
</result>
</action>
<!-- 重新合作 -->
<action name="newsupupdate" class="com.oak.action.SupplierAction" method="newsupplier" >
<result name="success" type="redirectAction">
sup_list
</result>
</action>
<action name="newsupdelete" class="com.oak.action.SupplierAction" method="newdelete">
<result name="success" type="redirectAction">
newproviderAdd
</result>
</action>
struts表单提交(4)和(3)相关的更多相关文章
- 【HTML相关】iframe+javascript实现一个表单提交后多个处理文件按序处理
最近在弄一个网页的问题,总结如下. [问题描述] 页面中包括以下几个部分:1)表单form,供用户输入图片文件:2)iframe1,显示a.php文件的内容,a.php接收客户端图片并保存,后台程序处 ...
- 原生JS 表单提交验证器
转载:http://www.cnblogs.com/sicd/p/4613628.html 一.前言 最近在开发一个新项目,需要做登陆等一系列的表单提交页面.在经过“缜密”的讨论后,我们决定 不用外部 ...
- 表单提交与后台PHP如何接口?
在网页中,常常有这样那样的表单需要提交,比如登陆,比如注册,比如查询,比如填写问卷.在这样的表单提交过程中,我们究竟向后台提交了什么,是以什么形式提交的,是一个很值得探讨的问题. 提交了什么——就是我 ...
- 详解JavaScript中的Url编码/解码,表单提交中网址编码
本文主要针对URI编解码的相关问题做了介绍,对Url编码中哪些字符需要编码.为什么需要编码做了详细的说明,并对比分析了Javascript 中和 编解码相关的几对函数escape / unescape ...
- form表单提交过程
本文为转载文章! 今天,我将站在HTML和单纯的Asp.net框架的角度来解释它们的工作方式,因此,本文不演示WebForms服务器控件的相关内容. 简单的表单,简单的处理方式 好了,让我们进入今天的 ...
- DWZ(JUI) 教程 普通表单提交
一类是普通的表单提交,另一类就是列表页面的表单提交,主要是用来查询搜索列表使用的.今天我就简单介绍一下前者. 这是官网上的普通列表页面, <div class="pageContent ...
- [学习笔记]--Jfinal 表单提交附件
近期.项目里面用到了Jfinal 里面的上传附件. Jfinal 的Controller 里面提供了一个 getFile系列方法提供文件上传. 我这里呢,是文件上传和表单參数一起提交. 页面类似下图: ...
- HTML5表单提交和PHP环境搭建
HTML5表单提交相关内容和PHP环境搭建需要的软件(只备注) (2)举例介绍 (3)PHP环境搭建
- 基于Http原理实现Android的图片上传和表单提交
版权声明:本文由张坤 原创文章,转载请注明出处: 文章原文链接:https://www.qcloud.com/community/article/794875001483009140 来源:腾云阁 ...
随机推荐
- Linux系统下GDB调试
GDB 一.gdb常用命令: 命令 描述 backtrace(或bt) 查看各级函数调用及参数 finish 连续运行到当前函数返回为止,然后停下来等待命令 frame(或f) 帧编号 选择栈帧 in ...
- 2017 ICPC西安区域赛 A - XOR (线段树并线性基)
链接:https://nanti.jisuanke.com/t/A1607 题面: Consider an array AA with n elements . Each of its eleme ...
- sysbench的简单安装
1. 下载 可以到网站上面找 我用到的这个是201908最新的 wget https://src.fedoraproject.org/repo/pkgs/sysbench/sysbench-1.0.1 ...
- ORACLE查询进程,并杀死
用于存放常用SQL --查询主键在哪一列 --设置页大小 --设置行大小 col COLUMN_NAME for a20 --设置字段显示长度 col TABLE_NAME for a20 col O ...
- 关于centOS安装配置xampp那点事
1.到官网下载centOS对应版本的xampp,应该是以tar.gz为后缀的 2.tar -zxf 下载的包 3.mv lampp /opt 4.service mysqld stop因xampp里自 ...
- Python取整数
1.向下取整: int()>>> a = 14.38>>> int(a)14 2.向上取整:ceil()使用ceil()方法时需要导入math模块,例如>&g ...
- python 基础例子 双色球 查询天气 查询电话
# 随机生成双色球import random# 随机数 1-16之间# r = random.randint(1,16)# print(r)phone_numbers_str = "匪警[1 ...
- Django Rest Framework 安装
1. 环境要求 Python (3.5, 3.6, 3.7): 查看 python版本:python -V Django (1.11, 2.0, 2.1, 2.2) 查看django版本:pip li ...
- PHP获取指定时间的前6个月月份 、获取前6天日期
//获取前6个月月份 public function to_sex_month(){ $today = input('param.today') ? input('param.today') : da ...
- .net core 根据数据库生成实体类
微软最近几年在跨平台上不断发力,很多.net程序员也摩拳擦掌,对微软寄以厚望.就在最近,微软还推出了asp .net core2.0预览版. 通过对.net core的简单尝试,我发现以往我们开发MV ...