通讯录改造——MVC设计模式
将之前用servlet写的程序转化为jsp+servlet的简单的MVC的三层结构。项目中程序的包如图
首先是实体对象:
- package com.contactSystem.entiey;
- public class Contact {
- private String Id;
- private String name;
- private String sex;
- private String age;
- private String phone;
- private String qq;
- private String email;
- public String getId() {
- return Id;
- }
- public void setId(String id) {
- Id = id;
- }
- public String getName() {
- return name;
- }
- public void setName(String name) {
- this.name = name;
- }
- public String getSex() {
- return sex;
- }
- public void setSex(String sex) {
- this.sex = sex;
- }
- public String getAge() {
- return age;
- }
- public void setAge(String age) {
- this.age = age;
- }
- public String getPhone() {
- return phone;
- }
- public void setPhone(String phone) {
- this.phone = phone;
- }
- public String getQq() {
- return qq;
- }
- public void setQq(String qq) {
- this.qq = qq;
- }
- public String getEmail() {
- return email;
- }
- public void setEmail(String email) {
- this.email = email;
- }
- @Override
- public String toString() {
- return "Contact [Id=" + Id + ", name=" + name + ", sex=" + sex
- + ", age=" + age + ", phone=" + phone + ", qq=" + qq
- + ", email=" + email + "]";
- }
- }
然后就是对数据操作的抽象类
- package com.contactSystem.dao;
- import java.io.FileNotFoundException;
- import java.io.UnsupportedEncodingException;
- import java.util.List;
- import org.dom4j.DocumentException;
- import com.contactSystem.entiey.Contact;
- public interface ContactOperate {
- public void addContact(Contact contact) throws Exception;
- public void updateContact(Contact contact) throws Exception;
- public void removeContact(String id) throws Exception;
- public Contact findContact(String id) throws Exception;
- public List<Contact> allContacts();
- //根据名称姓名查询是否有存在重复。
- public boolean checkIfContact(String name);
- }
具体实现类
- package com.contactSystem.dao.daoImpl;
- import java.io.File;
- import java.util.ArrayList;
- import java.util.List;
- import java.util.UUID;
- import javax.persistence.Id;
- import javax.persistence.Tuple;
- import org.dom4j.Document;
- import org.dom4j.DocumentHelper;
- import org.dom4j.Element;
- import org.dom4j.io.SAXReader;
- import com.contactSystem.dao.ContactOperate;
- import com.contactSystem.entiey.Contact;
- import com.contactSystem.util.XMLUtil;
- public class Operater implements ContactOperate {
- @Override
- //添加联系人
- public void addContact(Contact contact) throws Exception {
- // TODO Auto-generated method stub
- File file=new File("e:/contact.xml");
- Document doc=null;
- Element rootElem=null;
- if (file.exists()) {
- doc=new SAXReader().read(file);
- rootElem=doc.getRootElement();
- }else {
- doc=DocumentHelper.createDocument();
- rootElem=doc.addElement("ContactList");
- }
- //开始添加个体
- Element element=rootElem.addElement("contact");
- //有系统自动生成一随机且唯一的ID,赋给联系人Id,系统提供了一个包UUID包
- String uuid=UUID.randomUUID().toString().replace("-", "");
- element.addAttribute("Id", uuid);
- element.addElement("姓名").setText(contact.getName());
- element.addElement("name").setText(contact.getName());
- element.addElement("sex").setText(contact.getSex());
- element.addElement("age").setText(contact.getAge());
- element.addElement("phone").setText(contact.getPhone());
- element.addElement("email").setText(contact.getEmail());
- element.addElement("qq").setText(contact.getQq());
- //写入到本地的xml文档中
- XMLUtil.write2xml(doc);
- }
- @Override
- public void updateContact(Contact contact) throws Exception {
- // TODO Auto-generated method stub
- //通过xpath查找对应id的联系人
- Document document=XMLUtil.getDocument();
- Element element=(Element) document.selectSingleNode("//contact[@Id='"+contact.getId()+"']");
- //根据标签改文本
- System.out.println(element);
- element.element("name").setText(contact.getName());
- element.element("age").setText(contact.getAge());
- element.element("email").setText(contact.getEmail());
- element.element("phone").setText(contact.getPhone());
- element.element("sex").setText(contact.getSex());
- element.element("qq").setText(contact.getQq());
- XMLUtil.write2xml(document);
- }
- @Override
- public void removeContact(String id) throws Exception {
- // TODO Auto-generated method stub
- //通过xpath去查找对应的contact
- Document document=XMLUtil.getDocument();
- Element element=(Element) document.selectSingleNode("//contact[@Id='"+id+"']");
- /**
- * 如果是火狐浏览器,其本身有一个bug,对于一个get请求,它会重复做两次,
- * 第一次会把一个唯一的id给删除掉,但是在第二次的时候,它会继续去删,而这个时候查找不到,会报错,会发生错误,
- * 为了解决这个bug,我们在这里验证其是否为空
- */
- if (element!=null) {
- element.detach();
- XMLUtil.write2xml(document);
- }
- }
- @Override
- public Contact findContact(String id) throws Exception {
- // TODO Auto-generated method stub
- Document document=XMLUtil.getDocument();
- Element e=(Element) document.selectSingleNode("//contact[@Id='"+id+"']");
- Contact contact=null;
- if (e!=null) {
- contact=new Contact();
- contact.setAge(e.elementText("age"));
- contact.setEmail(e.elementText("email"));
- contact.setId(id);
- contact.setName(e.elementText("name"));
- contact.setPhone(e.elementText("phone"));
- contact.setSex(e.elementText("sex"));
- contact.setQq(e.elementText("qq"));
- }
- return contact;
- }
- @Override
- public List<Contact> allContacts() {
- // TODO Auto-generated method stub
- Document document=XMLUtil.getDocument();
- List<Contact> list=new ArrayList<Contact>();
- List<Element> conElements=(List<Element>)document.selectNodes("//contact");
- for (Element element : conElements) {
- Contact contact=new Contact();
- contact.setId(element.attributeValue("Id"));
- contact.setAge(element.elementText("age"));
- contact.setEmail(element.elementText("email"));
- contact.setName(element.elementText("name"));
- contact.setPhone(element.elementText("phone"));
- contact.setQq(element.elementText("qq"));
- contact.setSex(element.elementText("sex"));
- list.add(contact);
- }
- return list;
- }
- /**
- * true:说明重复
- * false:说明没有重复
- */
- @Override
- public boolean checkIfContact(String name) {
- // TODO Auto-generated method stub
- //查询name标签是否一样
- Document doc=XMLUtil.getDocument();
- Element element=(Element) doc.selectSingleNode("//name[text()='"+name+"']");
- if (element!=null) {
- return true;
- }else {
- return false;
- }
- }
- }
为了减轻Servlet的负担在增加一层(业务逻辑层)Service,这里举例,当联系人的名字存在时,提示出错,不在servlet中去判断,而在service中去处理,同样首先写出service抽象接口
- package com.contactSystem.service;
- import java.util.List;
- import com.contactSystem.entiey.Contact;
- public interface ContactService {
- public void addContact(Contact contact) throws Exception;
- public void updateContact(Contact contact) throws Exception;
- public void removeContact(String id) throws Exception;
- public Contact findContact(String id) throws Exception;
- public List<Contact> allContacts();
- }
这个时候有点相当于在Operate操作中添加了一层操作,在contactService的实现类中去有逻辑判断的去使用Operater的方法
- package com.contactSystem.service.imple;
- import java.util.List;
- import com.contactSystem.dao.daoImpl.Operater;
- import com.contactSystem.entiey.Contact;
- import com.contactSystem.exception.NameRepeatException;
- import com.contactSystem.service.ContactService;
- /**
- * 处理项目中出现的业务逻辑
- * @author Administrator
- *
- */
- public class ContactServiceImpe implements ContactService {
- Operater operater =new Operater();
- @Override
- public void addContact(Contact contact) throws Exception {
- // TODO Auto-generated method stub
- //执行业务逻辑判断
- /**
- * 添加是否重复的业务逻辑
- */
- if (operater.checkIfContact(contact.getName())) {
- //重复
- /**
- * 注意:如果业务层方法出现任何错误,则返回标记(自定义的异常)到servlet
- */
- throw new NameRepeatException("姓名重复,不可使用");
- }
- operater.addContact(contact);
- }
- @Override
- public void updateContact(Contact contact) throws Exception {
- // TODO Auto-generated method stub
- operater.updateContact(contact);
- }
- @Override
- public void removeContact(String id) throws Exception {
- // TODO Auto-generated method stub
- operater.removeContact(id);
- }
- @Override
- public Contact findContact(String id) throws Exception {
- // TODO Auto-generated method stub
- return operater.findContact(id);
- }
- @Override
- public List<Contact> allContacts() {
- // TODO Auto-generated method stub
- return operater.allContacts();
- }
- }
这里通过抛出异常去将信息传递给Servlet,异常代码如下
- package com.contactSystem.exception;
- /**
- * 姓名重复的自定义异常
- * @author Administrator
- *
- */
- public class NameRepeatException extends Exception{
- public NameRepeatException(String msg) {
- super(msg);
- }
- }
现在来写Servlet,首先是首页的联系人列表Servlet
- package com.contactSystem.servlet;
- import java.io.IOException;
- import java.io.PrintWriter;
- import java.util.ArrayList;
- import java.util.List;
- import javax.servlet.ServletException;
- import javax.servlet.http.HttpServlet;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import com.contactSystem.dao.daoImpl.Operater;
- import com.contactSystem.entiey.Contact;
- import com.contactSystem.service.ContactService;
- import com.contactSystem.service.imple.ContactServiceImpe;
- public class Index extends HttpServlet {
- /**
- * 显示所有联系人的逻辑方式
- */
- private static final long serialVersionUID = 1L;
- public void doGet(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException {
- response.setContentType("text/html;charset=utf-8");
- ContactService service=new ContactServiceImpe();
- List<Contact> contacts=service.allContacts();
- /**
- * shift+alt+A ——>区域选择
- * 正则表达式:“."表示任意字符,"*"表示多个字符
- * “/1”表示一行代表匹配一行内容
- */
- request.setAttribute("contacts", contacts);
- request.getRequestDispatcher("/index.jsp").forward(request, response);
- }
- public void doPost(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException {
- this.doGet(request, response);
- }
- }
添加联系人
- package com.contactSystem.servlet;
- import java.io.IOException;
- import java.io.PrintWriter;
- import javax.servlet.ServletException;
- import javax.servlet.http.HttpServlet;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import com.contactSystem.dao.daoImpl.Operater;
- import com.contactSystem.entiey.Contact;
- import com.contactSystem.exception.NameRepeatException;
- import com.contactSystem.service.ContactService;
- import com.contactSystem.service.imple.ContactServiceImpe;
- public class addServlet extends HttpServlet {
- /**
- * 处理添加联系人的逻辑
- */
- private static final long serialVersionUID = 1L;
- public void doGet(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException {
- request.setCharacterEncoding("utf-8");
- String userName=request.getParameter("userName");
- String age=request.getParameter("age");
- String sex=request.getParameter("sex");
- String phone=request.getParameter("phone");
- String qq=request.getParameter("qq");
- String email=request.getParameter("email");
- ContactService service=new ContactServiceImpe();
- Contact contact=new Contact();
- contact.setName(userName);
- contact.setAge(age);
- contact.setSex(sex);
- contact.setPhone(phone);
- contact.setQq(qq);
- contact.setEmail(email);
- try {
- service.addContact(contact);
- } catch (NameRepeatException e) {
- // TODO Auto-generated catch block
- //处理名字重复的异常
- request.setAttribute("message", e.getMessage());
- request.getRequestDispatcher("/add.jsp").forward(request, response);
- return;
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- response.sendRedirect(request.getContextPath()+"/Index");
- }
- public void doPost(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException {
- this.doGet(request, response);
- }
- }
查找联系人
- package com.contactSystem.servlet;
- import java.io.IOException;
- import java.io.PrintWriter;
- import javax.servlet.ServletException;
- import javax.servlet.http.HttpServlet;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import com.contactSystem.dao.daoImpl.Operater;
- import com.contactSystem.entiey.Contact;
- import com.contactSystem.service.ContactService;
- import com.contactSystem.service.imple.ContactServiceImpe;
- public class FindIdServlet extends HttpServlet {
- /**
- * 修改联系人逻辑
- */
- private static final long serialVersionUID = 1L;
- public void doGet(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException {
- response.setContentType("text/html;charset=utf-8");
- ContactService service=new ContactServiceImpe();
- String id=request.getParameter("id");
- Contact contact=null;
- try {
- contact=service.findContact(id);
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- request.setAttribute("contact", contact);
- request.getRequestDispatcher("/update.jsp").forward(request, response);
- }
- public void doPost(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException {
- this.doGet(request, response);
- }
- }
修改联系人
- package com.contactSystem.servlet;
- import java.io.IOException;
- import java.io.PrintWriter;
- import javax.servlet.ServletException;
- import javax.servlet.http.HttpServlet;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import com.contactSystem.dao.daoImpl.Operater;
- import com.contactSystem.entiey.Contact;
- import com.contactSystem.service.ContactService;
- import com.contactSystem.service.imple.ContactServiceImpe;
- public class UpdateServlet extends HttpServlet {
- /**
- * 将修改后的数据提交
- */
- private static final long serialVersionUID = 1L;
- public void doGet(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException {
- response.setContentType("text/html");
- request.setCharacterEncoding("utf-8");
- String userName=request.getParameter("userName");
- String age=request.getParameter("age");
- String sex=request.getParameter("sex");
- String phone=request.getParameter("phone");
- String qq=request.getParameter("qq");
- String email=request.getParameter("email");
- String id=request.getParameter("id");
- ContactService service=new ContactServiceImpe();
- Contact contact=new Contact();
- contact.setId(id);
- contact.setName(userName);
- contact.setAge(age);
- contact.setSex(sex);
- contact.setPhone(phone);
- contact.setQq(qq);
- contact.setEmail(email);
- try {
- service.updateContact(contact);
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- response.sendRedirect(request.getContextPath()+"/Index");
- }
- public void doPost(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException {
- this.doGet(request, response);
- }
- }
删除联系人
- package com.contactSystem.servlet;
- import java.io.IOException;
- import java.io.PrintWriter;
- import javax.servlet.ServletException;
- import javax.servlet.http.HttpServlet;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import com.contactSystem.dao.daoImpl.Operater;
- import com.contactSystem.service.ContactService;
- import com.contactSystem.service.imple.ContactServiceImpe;
- public class DeleteServlet extends HttpServlet {
- public void doGet(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException {
- response.setContentType("text/html;charset=utf-8");
- String id=request.getParameter("id");
- ContactService service=new ContactServiceImpe();
- try {
- service.removeContact(id);
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- response.sendRedirect(request.getContextPath()+"/Index");
- }
- public void doPost(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException {
- this.doGet(request, response);
- }
- }
以上完成了MVC的M和C,还差View,现在来具体显示jsp页面
首页所有联系人的显示
- <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
- <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset='utf-8'>
- <title>查询所有联系人</title>
- <style media='screen'>
- table td {
- text-align: center;
- }
- table {
- border-collapse: collapse;
- }
- </style>
- </head>
- <body>
- <center>
- <h2>查询所有联系人</h2>
- </center>
- <table border='1' align='center'>
- <tbody>
- <thead>
- <th>编号</th>
- <th>姓名</th>
- <th>性别</th>
- <th>年龄</th>
- <th>电话</th>
- <th>QQ</th>
- <th>邮箱</th>
- <th>操作</th>
- </thead>
- <c:forEach items="${contacts}" var="con" varStatus="varSta">
- <tr>
- <td>${varSta.count }</td>
- <td>${con.name }</td>
- <td>${con.sex }</td>
- <td>${con.age }</td>
- <td>${con.phone }</td>
- <td>${con.qq }</td>
- <td>${con.email }</td>
- <td><a href='${pageContext.request.contextPath }/FindIdServlet?id=${con.id}'>修改</a> <a href='${pageContext.request.contextPath }/DeleteServlet?id=${con.id}'>删除</a></td>
- </tr>
- </c:forEach>
- <tr>
- <td colspan='8'>
- <a href='${pageContext.request.contextPath}/add.jsp'>添加联系人</a>
- </td>
- </tr>
- </tbody>
- </table>
- </body>
- </html>
修改联系人,首先要把要修改联系人的信息都显示在信息栏中,然后用户去修改相关信息
- <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
- <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <title>修改联系人</title>
- <style media="screen">
- #btn{
- width:40px;
- width: 50px;
- background: green;
- color: white;
- font-size:14px;
- }
- </style>
- </head>
- <body>
- <center>
- <h2>修改联系人</h2>
- </center>
- <form action="${pageContext.request.contextPath }/UpdateServlet" method="post">
- <table border="1" align="center">
- <tbody>
- <tr>
- <th>姓名</th>
- <td><input type="text" name="userName" value="${contact.name}"/></td>
- <input type="hidden" name="id" value="${contact.id }"/>
- </tr>
- <tr>
- <th>年龄</th>
- <td><input type="text" name="age" value="${contact.age }" /></td>
- </tr>
- <tr>
- <th>性别</th>
- <td>
- <input type="radio" name="sex" value="男" <c:if test="${contact.sex=='男' }"> checked="true"</c:if>/>男
- <input type="radio" name="sex" value="女" <c:if test="${contact.sex=='女' }"> checked="true"</c:if> />女
- </td>
- </tr>
- <tr>
- <th>电话</th>
- <td><input type="text" name="phone" value="${contact.phone }" /></td>
- </tr>
- <tr>
- <th>QQ</th>
- <td><input type="text" name="qq" value="${contact.qq }" /></td>
- </tr>
- <tr>
- <th>邮箱</th>
- <td><input type="text" name="email" value="${contact.email }" /></td>
- </tr>
- <tr>
- <td colspan="3" align="center">
- <input type="submit" value="提交" id="btn"/>
- </td>
- </tr>
- </tbody>
- </table>
- </form>
- </body>
- </html>
最后就是添加联系人了
- <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
- <%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <title>添加联系人</title>
- <style media="screen">
- #btn{
- width:40px;
- width: 50px;
- background: green;
- color: white;
- font-size:14px;
- }
- </style>
- </head>
- <body>
- <center>
- <h2>添加联系人</h2>
- </center>
- <form action="${pageContext.request.contextPath}/addServlet" method="post">
- <table border="1" align="center">
- <tbody>
- <tr>
- <th>姓名</th>
- <td><input type="text" name="userName" value="${message }" /></td>
- </tr>
- <tr>
- <th>年龄</th>
- <td><input type="text" name="age" /></td>
- </tr>
- <tr>
- <th>性别</th>
- <td>
- <input type="radio" name="sex" value="男"/>男
- <input type="radio" name="sex" value="女" />女
- </td>
- </tr>
- <tr>
- <th>电话</th>
- <td><input type="text" name="phone" /></td>
- </tr>
- <tr>
- <th>QQ</th>
- <td><input type="text" name="qq" /></td>
- </tr>
- <tr>
- <th>邮箱</th>
- <td><input type="text" name="email" /></td>
- </tr>
- <tr>
- <td colspan="3" align="center">
- <input type="submit" value="提交" id="btn"/>
- </td>
- </tr>
- </tbody>
- </table>
- </form>
- </body>
- </html>
最后可以加上一个测试类,方便自己调试
- package com.contactSystem.Junit;
- import static org.junit.Assert.*;
- import java.util.List;
- import org.junit.Before;
- import com.contactSystem.dao.daoImpl.Operater;
- import com.contactSystem.entiey.Contact;
- public class Test {
- Operater operator=null;
- //初始化这个对象的实例
- @Before
- public void init(){
- operator=new Operater();
- }
- @org.junit.Test
- public void Add() throws Exception{
- Contact contact=new Contact();
- contact.setAge("21");
- contact.setEmail("454444@qq.com");
- contact.setName("gqxing");
- contact.setPhone("13455555");
- contact.setQq("235346662");
- contact.setSex("男");
- operator.addContact(contact);
- }
- @org.junit.Test
- public void update() throws Exception{
- Contact contact=new Contact();
- contact.setId("002");
- contact.setAge("0");
- contact.setEmail("0000000@qq.com");
- contact.setName("test");
- contact.setPhone("0-00000000000");
- contact.setQq("000000000000");
- contact.setSex("男");
- operator.updateContact(contact);
- }
- @org.junit.Test
- public void removeContact() throws Exception{
- operator.removeContact("002");
- }
- @org.junit.Test
- public void findContact() throws Exception{
- Contact contact=operator.findContact("002");
- System.out.println(contact);
- }
- @org.junit.Test
- public void allContact() throws Exception{
- List<Contact> contacts= operator.allContacts();
- for (Contact contact : contacts) {
- System.out.println(contact);
- }
- }
- @org.junit.Test
- public void TetsCheckBoolean() throws Exception{
- Boolean flag=operator.checkIfContact("郭庆兴");
- System.out.println(flag);
- }
- }
最后运行的结构示意图:
当名字重复的时候:提交就会显示
通讯录改造——MVC设计模式的更多相关文章
- AngularJS_01之基础概述、设计原则及MVC设计模式
1.AngularJS: 开源的JS框架,用来开发单一页面应用,以及数据操作频繁的场景:2.设计原则: ①YAGNI原则:You Aren't Gonna Need It! 不要写不需要的代码! ②K ...
- 谈谈JAVA工程狮面试中经常遇到的面试题目------什么是MVC设计模式
作为一名java工程狮,大家肯定经历过很多面试,但每次几乎都会被问到什么是MVC设计模式,你是怎么理解MVC的类似这样的一系列关于MVC的问题. [出现频率] [关键考点] MVC的含义 MVC的结构 ...
- Java Web开发中MVC设计模式简介
一.有关Java Web与MVC设计模式 学习过基本Java Web开发的人都已经了解了如何编写基本的Servlet,如何编写jsp及如何更新浏览器中显示的内容.但是我们之前自己编写的应用一般存在无条 ...
- MVC设计模式与三层架构
三层架构分别是:表示层(Web层).业务逻辑层(BLL层)和数据访问层(DAL层). (1)表示层负责: a.从用户端收集信息 b.将用户信息发送到业务服务层做处理 c.从业务服务层接收处理结果 d. ...
- 传智播客JavaWeb day07、day08-自定义标签(传统标签和简单标签)、mvc设计模式、用户注册登录注销
第七天的课程主要是讲了自定义标签.简单介绍了mvc设计模式.然后做了案例 1. 自定义标签 1.1 为什么要有自定义标签 前面所说的EL.JSTL等技术都是为了提高jsp的可读性.可维护性.方便性而取 ...
- mvc设计模式和mvc框架的区别
Spring中的新名称也太多了吧!IOC/DI/MVC/AOP/DAO/ORM... 对于刚刚接触spring的我来说确实晕了头!可是一但你完全掌握了一个概念,那么它就会死心塌地的为你服务了.这可比女 ...
- MVC设计模式((javaWEB)在数据库连接池下,实现对数据库中的数据增删改查操作)
设计功能的实现: ----没有业务层,直接由Servlet调用DAO,所以也没有事务操作,所以从DAO中直接获取connection对象 ----采用MVC设计模式 ----采用到的技术 .MVC设计 ...
- MVC设计模式(持续更新中)
MVC设计模式--->英文全称为: model(模型) View (视图) Controller(控制) MVC是一种设计思想.这种思想强调实现模型(Model).视图(View)和控制 ...
- iOS中MVC设计模式
在组织大型项目的代码文件时,我们常用MVC的思想.MVC的概念讲起来非常简单,就和对象(object)一样.但是理解和应用起来却非常困难.今天我们就简单总结一下MVC设计理念. MVC(Model V ...
随机推荐
- osg学习笔记3 简单几何模型
osg::Geode (geometry node) osg::Geode类表示场景中的渲染几何叶节点,它包含了渲染用的几何信息,没有子节点. 要绘制的几何数据保存在osg::Geode管理的一组os ...
- 数据库 - FMDB
FMDB 是基于 SQLite 封装的 面向对对象(OC) 的API. FMDB是iOS平台的SQLite数据库框架 FMDB以OC的方式封装了SQLite的C语言API FMDB 需要libsqli ...
- IOS7,做为开发者,你需要知道的变更
IOS7即将发布,那么我们需要做些什么呢? 升级你的程序Icon至 120*120 更新一张包含状态栏大小的闪屏图片 还有些什么东西呢? IOS7中需要使用更加扁平化的设计,所以BUTTON的图片,边 ...
- 第 17 章 责任链模式【Chain of Responsibility Pattern】
以下内容出自:<<24种设计模式介绍与6大设计原则>> 中国古代对妇女制定了“三从四德”的道德规范,“三从”是指“未嫁从父.既嫁从夫.夫死从子”,也就是说一个女性,在没有结婚的 ...
- Java中double类型的数据精确到小数点后两位
Java中double类型的数据精确到小数点后两位 多余位四舍五入,四种方法 一: double f = 111231.5585;BigDecimal b = new BigDecimal(f); d ...
- jquery多级手风琴插件–accordion.js
手风琴菜单一般用于下拉导航,由于外观非常简洁,使用起来跟手风琴一样可以拉伸和收缩而得名,项目中适当应用手风琴效果会给用户带来非常好的体验.本文借助jQuery插件轻松打造一个非常不错的手风琴效果的菜单 ...
- Hard Life
poj3155:http://poj.org/problem?id=3155 题意:最大密度子图的模板题. 题解:直接看代码. /* 题意简述一个公司有n个人,给出了一些有冲突的人的对数(u,v),所 ...
- 《鸟哥的Linux私房菜》读书笔记三
1.在Linux系统中,每个设备都被当成一个文件来对待,每个设备都会有设备文件名.比如 IDE接口的硬盘文件名为/dev/hd[a-d] 括号内的字母为a-d当中任意一个,即/dev/hda,/dev ...
- BZOJ_1565_[NOI2009]_植物大战僵尸_(Tarjan+最大流+最大权闭合图)
描述 http://www.lydsy.com/JudgeOnline/problem.php?id=1565 n*m的矩阵,可以种植植物,僵尸从图的右边进入吃植物.前面的植物可以保护后面的植物,还有 ...
- WordPress Cart66 Lite插件跨站请求伪造漏洞
漏洞名称: WordPress Cart66 Lite插件跨站请求伪造漏洞 CNNVD编号: CNNVD-201310-524 发布时间: 2013-10-23 更新时间: 2013-10-23 危害 ...