优秀的设计网站wordpress 视频教程

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

优秀的设计网站,wordpress 视频教程,营销型网站建设制作推广,那些网站平台可以做3d建模准备环境

  1. 添加web 点击项目右键——选择添加框架选择web应用程序 2.创建lib目录 在web应用程序的WEB-INF目录下创建lib目录添加jar包(5个)解压#xff1a;右键——选择添加库 3.创建Dao层 在src目录下创建包com.zmq在该包下创建dao层添加工具…准备环境
  2. 添加web 点击项目右键——选择添加框架选择web应用程序 2.创建lib目录 在web应用程序的WEB-INF目录下创建lib目录添加jar包(5个)解压右键——选择添加库 3.创建Dao层 在src目录下创建包com.zmq在该包下创建dao层添加工具类BaseDao创建相应的类继承BaseDao
  3. 添加属性文件 在src目录下添加属性文件
  4. 创建实体层entity 在com.zmq包下创建entity包在该包下创建相应的实体类
  5. 添加配置 选择tomcat 服务器——选择本地——启动服务器 1.登录 UserDao——封装方法 //登录public User selectByNameAndPwd(String name,String password){User usernull;try {getCon();String sqlselect * from user where u_name?password?;pscon.prepareStatement(sql);ps.setObject(1,name);ps.setObject(2,password);rsps.executeQuery();while(rs.next()){usernew User();user.setId(rs.getInt(id));user.setName(rs.getString(u_name));user.setPassword(rs.getString(password));}} catch (Exception e) {throw new RuntimeException(e);} finally {closeAll();}return user;}TextUserDao——单元测试 Testpublic void testSelectByNAP(){userDao.selectByNameAndPwd(张四,123456);}login.jsp——登录页面 body%//获取error的值String error request.getParameter(error);//判断如果error为1表示输入的密码或用户名有误if(1.equals(error)){out.print(font colorred用户名或密码有误/font);}%form actionloginDo.jsp methodpost账号input typetext namename/br密码input typepassword namepassword/brinput typesubmit value登录/input typebutton onclickregister() value注册//form/bodyloginDo.jsp——登录处理页面 body %//设置编码request.setCharacterEncoding(utf-8);//接收数据String name request.getParameter(name);String password request.getParameter(password);//调用UserDao中的方法UserDao userDaonew UserDao();User user userDao.selectByNameAndPwd(name, password);//依据返回值user是否为空判断输入密码用户名是否正确if(user!null){response.sendRedirect(success.jsp);}else {response.sendRedirect(login.jsp?error1);} % /body2. 注册 UserDao——封装方法 //注册public int add(String name,String password){String sqlinsert into user values(null,?,?);return edit(sql,name,password);}TestUserDao——单元测试 UserDao userDaonew UserDao();Testpublic void testAdd(){userDao.add(张数,123456);}login.jsp——登录页面 body%//获取error的值String error request.getParameter(error);//判断如果error为1表示输入的密码或用户名有误if(1.equals(error)){out.print(font colorred用户名或密码有误/font);}%form actionsuccess.jsp methodpost账号input typetext namename/br密码input typepassword namepassword/brinput typesubmit value登录/input typebutton onclickregister() value注册//form/body scriptfunction register(){location.hrefregister.jsp;} /scriptregister.jsp——注册页面 body form actionregisterDo.jsp methodpost账号input typetext namename1/br密码input typetext namepassword1/brinput typesubmit value注册/ /formregisterDo.jsp——注册处理页面 body %//设置编码request.setCharacterEncoding(utf-8);//接收数据String name1 request.getParameter(name1);String password1 request.getParameter(password1);//调用UserDao中的方法UserDao userDaonew UserDao();int add userDao.add(name1, password1);if(add0){response.sendRedirect(login.jsp);}else {response.sendRedirect(register.jsp);} % /body3. 查询全部并显示 BooksDao——封装方法 //查询所有图书信息public ListBooks selectAll(){ListBooks listnew ArrayList();try {getCon();String sqlselect * from books;pscon.prepareStatement(sql);rs ps.executeQuery();while (rs.next()){Books booksnew Books();books.setId(rs.getInt(book_id));books.setType(rs.getString(type_id));books.setName(rs.getString(book_name));books.setAuthor(rs.getString(author));books.setPublisher(rs.getString(publisher));books.setPrice(rs.getInt(price));list.add(books);}} catch (Exception e) {throw new RuntimeException(e);} finally {closeAll();}return list;}TestBooksDao——单元测试输出书本名字 BooksDao booksDaonew BooksDao();Testpublic void testSelectAll(){ListBooks list booksDao.selectAll();for (Books b: list) {System.out.println(b.getName());}}success.jsp——登录成功后的显示页面 headtitleTitle/titlestylediv{color: black;text-align: center;}a{text-decoration: none;}/style /head body %BooksDao booksDaonew BooksDao();ListBooks list booksDao.selectAll(); % div登录成功页面/div button添加/buttonbr table border1px aligncenter width70% cellspacing0trth编emsp;号/thth类emsp;型/thth名emsp;称/thth作emsp;者/thth出版社/thth价emsp;格/thth操emsp;作/th/tr%for (Books b:list) {%trtd%b.getId()%/tdtd%b.getType()%/tdtd%b.getName()%/tdtd%b.getAuthor()%/tdtd%b.getPublisher()%/tdtd%b.getPrice()%/tdtda href#编辑/aa href#删除/a/td/tr%}% /table/body4. 增加 BooksDao——封装方法 //增加public int add(String type,String name,String author,String publisher,Integer price){String sqlinsert into books values(null,?,?,?,?,?);return edit(sql,type,name,author,publisher,price);}TestBooksDao——单元测试 Testpublic void testAdd(){booksDao.add(CMP,活着,余华,清华大学出版社,23);}success.jsp——登录成功后的显示页面 button onclickadd()添加/buttonbr scriptfunction add(){location.hrefadd.jsp;} /scriptadd.jsp添加页面 body form actionaddDo.jsp methodpost类emsp;型input typetext nametypes/br名emsp;称input typetext namenames/br作emsp;者input typetext nameauthors/br出版社input typetext namepublishers/br价emsp;格input typenumber nameprices/brinput typesubmit value确认添加/ /form/bodyaddDo.jsp添加处理页面 body %//设置编码格式request.setCharacterEncoding(utf-8);//接收数据String types request.getParameter(types);String names request.getParameter(names);String authors request.getParameter(authors);String publishers request.getParameter(publishers);String prices request.getParameter(prices);//调用BooksDao中的方法BooksDao booksDaonew BooksDao();int add booksDao.add(types, names, authors, publishers, Integer.parseInt(prices));//判断if(add0){response.sendRedirect(success.jsp);}else {response.sendRedirect(add.jsp);}% /body5. 删除 BooksDao——封装方法 //删除public int delete(Integer id){String sqldelete from books where book_id?;return edit(sql,id);}TestBooksDao——单元测试 Testpublic void testDel(){booksDao.delete(4);}success.jsp——登录成功后的显示页面 a hrefdelDo.jsp?id%b.getId()%删除/adeleteDo.jsp删除操作页面 body %//接收数据String id request.getParameter(id);//调用BooksDao中的方法BooksDao booksDaonew BooksDao();int delete booksDao.delete(Integer.parseInt(id));if(delete0){out.print(scriptalert(删除成功);location.hrefsuccess.jsp/script);}else{out.print(scriptalert(删除失败);location.hrefsuccess.jsp/script);} % /body6. 修改 6.1数据回显 BooksDao——封装方法 //根据id查询public Books selectById(Integer id){Books booksnull;try {getCon();String sqlselect * from books where book_id?;pscon.prepareStatement(sql);ps.setObject(1,id);rsps.executeQuery();while (rs.next()){booksnew Books();books.setId(rs.getInt(book_id));books.setType(rs.getString(type_id));books.setName(rs.getString(book_name));books.setAuthor(rs.getString(author));books.setPublisher(rs.getString(publisher));books.setPrice(rs.getInt(price));}} catch (Exception e) {throw new RuntimeException(e);} finally {closeAll();}return books;}TestBooksDao——单元测试 Testpublic void testSelectById(){booksDao.selectById(1);}success.jsp——登录成功后的显示页面 a hrefupdate.jsp?id%b.getId()%编辑/aupdate.jsp修改页面根据id查询并数据回显 body%//接收数据String id request.getParameter(id);//调用BooksDao中的方法BooksDao booksDaonew BooksDao();Books books booksDao.selectById(Integer.parseInt(id));% form actionupdateDo.jsp methodpostinput typehidden nameid value%id%br类emsp;型input typetext nametype value%books.getType()%/br名emsp;称input typetext namename value%books.getName()%/br作emsp;者input typetext nameauthor value%books.getAuthor()%/br出版社input typetext namepublisher value%books.getPublisher()%/br价emsp;格input typenumber nameprice value%books.getPrice()%/brinput typesubmit value确认修改/ /form /body6.2确认修改 BooksDao——封装方法 //修改public int update(String type,String name,String author,String publisher,Integer price,Integer id){String sqlupdate books set type_id?,book_name?,author?,publisher?,price? where book_id?;return edit(sql,type,name,author,publisher,price,id);}TestBooksDao——单元测试 Testpublic void testUpdate(){booksDao.update(CMP,活着,余华,天津大学出版社,19,309108);}updateDo.jsp修改操作页面修改数据信息并同步到数据库 body %//设置编码request.setCharacterEncoding(utf-8);//接收数据String id request.getParameter(id);String type request.getParameter(type);String name request.getParameter(name);String author request.getParameter(author);String publisher request.getParameter(publisher);String price request.getParameter(price);//调用BooksDao的方法BooksDao booksDaonew BooksDao();booksDao.update(type,name,author,publisher,Integer.parseInt(price),Integer.parseInt(id));response.sendRedirect(success.jsp); % /body7. 测试功能是否正确 测试写的功能有两种方法 使用主函数使用junit单元测试 步骤 加入单元测试的依赖——junit的jar包创建一个测试类——包含相应的测试方法 //注意:该方法没有参数也没有返回值。StudentDao studentDaonew StudentDao();Testpublic void testFindAll(){ListStudent list studentDao.findAll();for(Student s:list){System.out.println(s.getName()—s.getAge());}}注意测试类中的方法没有参数也没有返回值要加Test注解测试时选中方法名——右键选择Run 8.注意
  6. 关于时间类型 数据库与Java类型的一一对照 data——data表示日期 time——time表示时间 timestamp——timestamp表示日期时间毫秒 获取数据getDate、getTime、getTimestamp数据库获取现在的时间now()
  7. 关于强转 String类型转换为Integer类型Integer. parseInt(变量) 3.关于性别 当数据库中使用1、2表示男女时在前端页面显示可以使用三目运算符 s.getGender1?男:女;4.关于超链接传参 ?keyvalue a hrefdelDo.jsp?id%s.getId()%删除/a5. 关于删除成功后弹出提示信息 if(delete0){out.print(scriptalert(删除成功);location.hrefsuccess.jsp/script);}else{out.print(scriptalert(删除失败);location.hrefsuccess.jsp/script);}使用script和alert 6.关于修改时的id 因为修改时id不可变且需要传递id值所以需要对id进行处理两种方法 使用隐藏域hidden将id在前端页面隐藏读取出id并设置为只读模式readonly
  8. 单选框、复选框的默认 单选框checked 复选框selected