当前位置: 首页 > news >正文

开发工具Eclipse的使用之导入项目(import)

🥳🥳Welcome Huihui's Code World ! !🥳🥳

接下来看看由辉辉所写的关于Eclipse使用的相关操作吧

目录

🥳🥳Welcome Huihui's Code World ! !🥳🥳

一.导读

二.详细操作步骤 

 1.右击项目处,点击import

 2.选择所要导入的项目所在路径

 3.导入项目完毕之后,需要检查是否有错误

 4.若报错,则检查配置的文件是否出现了问题

 5.将报错的文件移除掉

 6.重新配置一个文件(注意版本)

 7.项目不报错之后,我们来看一下数据库辅助类​编辑

 8.核对账号密码的信息

 9.再选择需要导入的对应数据库脚本

10.选择运行的jsp界面即可,若成功运行,则没有问题

11.我们再参照这个项目中的代码,完成一个简单的增删改查

entity

dao

servlet

运行结果


一.导读

上篇我们已经详细介绍了开发工具eclipse,也说明了eclipse的基本使用,那么我们这篇来详细讲述一下怎么导入项目

二.详细操作步骤 

1.右击项目处,点击import

2.选择所要导入的项目所在路径

 3.导入项目完毕之后,需要检查是否有错误

  4.若报错,则检查配置的文件是否出现了问题

 5.将报错的文件移除掉

 6.重新配置一个文件(注意版本)

 7.项目不报错之后,我们来看一下数据库辅助类

 8.核对账号密码的信息

 9.再选择需要导入的对应数据库脚本

 10.选择运行的jsp界面即可,若成功运行,则没有问题

11.我们再参照这个项目中的代码,完成一个简单的增删改查

entity

package com.wh.entity;public class Cat {
int cid;
String cname;
int age;public Cat() {// TODO Auto-generated constructor stub
}public Cat(int cid, String cname, int age) {super();this.cid = cid;this.cname = cname;this.age = age;
}public int getCid() {return cid;
}public void setCid(int cid) {this.cid = cid;
}public String getCname() {return cname;
}public void setCname(String cname) {this.cname = cname;
}public int getAge() {return age;
}public void setAge(int age) {this.age = age;
}@Override
public String toString() {return "Cat [cid=" + cid + ", cname=" + cname + ", age=" + age + "]";
}}

dao

package com.wh.dao;import java.util.List;import com.zking.util.BaseDao;
import com.zking.util.PageBean;
import com.zking.util.StringUtils;public class CatDao extends BaseDao<Cat>{public List<Cat> list(Cat cat,PageBean pageBean) throws Exception{String sql = "select * from t_mvc_cat where 1 =1 ";String title = cat.getCname();int id = cat.getCid();if(StringUtils.isNotBlank(title)) {sql += " and title like '%"+title+"%'";}if(id != 0) {sql += " and cid = "+id;}return super.executeQuery(sql, Cat.class, pageBean);}public void add(Cat cat) throws Exception {String sql = "insert into t_mvc_cat(cid,cname,age) values(?,?,?)";super.executeUpdate(sql, cat, new String[] {"cid","cname","age"});}public void delete(Cat cat) throws Exception {String sql = "delete from t_mvc_cat where cid = ?";super.executeUpdate(sql, cat, new String[] {"cid"});}public void edit(Cat cat) throws Exception {String sql = "update t_mvc_cat set cname = ?,age = ? where cid = ?";super.executeUpdate(sql, cat, new String[] {"cname","age","cid"});}
}

servlet

package com.wh.web;import java.util.List;import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;import com.wh.dao.CatDao;
import com.zking.entity.Cat;
import com.zking.framework.ActionSupport;
import com.zking.framework.ModelDriver;
import com.zking.util.PageBean;public class CatAction extends ActionSupport implements ModelDriver<Cat>{public Cat cat = new Cat();public CatDao catDao = new CatDao();@Overridepublic Cat getModel() {return cat;}public String list(HttpServletRequest req, HttpServletResponse resp) {
//		查数据库的PageBean pageBean = new PageBean();pageBean.setRequest(req);try {List<Cat> list = catDao.list(cat, pageBean);req.setAttribute("cats", list);req.setAttribute("pageBean", pageBean);} catch (Exception e) {e.printStackTrace();}return "list";}public String add(HttpServletRequest req, HttpServletResponse resp) {try {catDao.add(cat);} catch (Exception e) {e.printStackTrace();}return "toList";}public String delete(HttpServletRequest req, HttpServletResponse resp) {try {catDao.delete(cat);} catch (Exception e) {e.printStackTrace();}return "toList";}public String edit(HttpServletRequest req, HttpServletResponse resp) {try {catDao.edit(cat);} catch (Exception e) {e.printStackTrace();}return "toList";}public String toEdit(HttpServletRequest req, HttpServletResponse resp) {if(cat.getCid()!= 0) {try {List<Cat> list = catDao.list(cat, null);req.setAttribute("c", list.get(0));} catch (Exception e) {e.printStackTrace();}}return "toEdit";}
}

 运行结果

       好啦,今天的分享就到这了,希望能够帮到你呢!😊😊             

http://www.lryc.cn/news/121883.html

相关文章:

  • decimal类型在MySQL中的正确使用 (长度和小数点)
  • Mongodb 安装
  • Java技术整理(5)—— Spring篇
  • 07-MySQL-基础篇-函数
  • 不同路径 II——力扣63
  • NLP文本分类
  • 进程和线程的联系与区别
  • 分支和循环语句(2)(C语言)
  • Flutter: A RenderFlex overflowed by 42 pixels on the bottom.
  • 第三章,矩阵,07-用初等变换求逆矩阵、矩阵的LU分解
  • STM32F429IGT6使用CubeMX配置SPI通信(W25Q256芯片)
  • C++11异步与通信之 packaged_task
  • 磁盘的管理
  • 数据结构:完全二叉树的性质
  • 【数据结构】‘双向链表’冲冲冲
  • Linux 编译CEF源码详细记录
  • LeetCode 2810. Faulty Keyboard【模拟,双端队列,字符串】简单
  • 两个数组的交集-C语言/Java
  • Arduino+esp32学习笔记
  • 计算机网络-专业术语
  • E. Maximum Monogonosity
  • 已解决Excel file format cannot be determined, you must specify an engine manually
  • Centos yum命令大全
  • 内网横向移动—ARP攻击图片捕捉数据劫持DNS劫持
  • react之Hooks的介绍、useState与useEffect副作用的使用
  • django——创建 Django 项目和 APP
  • == 和 equals 的对比 [面试题]
  • SpringBoot集成Redis及Redis使用方法
  • Redis可以用作数据库吗?它的适用场景是什么?
  • @Param详解