之前对JavaEE的MVC模式有些许了解,但一直没有很好的掌握,在读代码时候也很模糊不清。因此对MVC又通过各种资料有了全面的理解。

一.首先,需要从了解JavaEE技术开始。JavaEE技术在设计程序时,一般会把程序的结构设计成三层。

●表示层—用户界面和用于生成界面的代码组成。

●中间层—系统的业务和功能代码。

●数据层—完成存储数据库的数据和对数据进行封装。

基于这种程序结构,有了MVC。M即为数据层,包括各种JavaBean以及数据库工具。V即为表示层,通常为Jsp或HTML页面,显示在客户端。C即为中间层,一般为Web层的Servlet组件,由它来处理客户端的各种请求以及数据。

二.MVC的简单应用:

1)Eclipse中的创建项目,项目名chapter11

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAOkAAADWCAIAAAC7eTLMAAASI0lEQVR4nO2dX2wcxR3H74V3PyDRVGqhNAWLqImwqqg9oRT1DwntQ1Kko3YFihXCtlIpSSxQTQvlMDKymkSsQhIskC9OwW4CmIYeuZqSyE4sO3FVNQdB5MACbMDCcmJqIlQdFen0Yc93M7u/2Z1dn293dr8fjSzf3u7O+Py58ex6vjcpFpQd+fxL77z93Gjf84Xbc30/+vUjh9ruP8IYK77UaduzedtBtVMWjFTanArcoqAUjFQqZRQUNoIokQp85I58/genZtoGjj/yyx8+eP/OO+7/y67f7/3o1CPv/HXXgcd6GGOb/3DU2rOB7k6ZaV/CTZnpVCptGMJR5EYQOTzcHRkZ6enpIZ86Vxy7Kzf5wyff2rbrpTu3PXfntsfPFcfYZ6crhVM2wu66HBXsVKBxuLl78uTJNWvW3HDDDbIdzhXH9j7y53u2P/Nwh3muOMYYYxfzlcLYi6cvNG872Lzt4KG/vyE5QcFIVUibUxV3zaVtVXGmzHTKts0Sq3a4URDOtvQWsJ1fPLD2NoG7WiJ11xK3tbXVxV2C2edrxYOCkbJ1s9wYc8pMV56cMo2lnQoG/3TNZHE7t7V6+up28UBme9ZzI4gQtLtVcdva2tzdnZ88NDOQmZ88xBhr355r395nla3b+9rv7dtqfX9vX/v2PvuRxADBZpvYMQo9r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9wJbm1MLpB6681zUzkEFeDfglBHcnutf+76ODiyXz+P47Fksm+/DgRPfaxjcD6E4I7s6e6Z/oXsuX2TP9jW8G0J1EzSMDseL/1VdFLFJ7lUkAAAAASUVORK5CYII=" alt="" />

2)模型实体Student

 package com.chapter11.bean;

 import java.sql.Date;

 public class Student {
private int id;
private String name;
private Date birthday;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Date getBirthday() {
return birthday;
}
public void setBirthday(Date birthday) {
this.birthday = birthday;
} }

JavaBean

3)数据库连接工具JdbcUtil

 package com.chapter11.util;

 import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement; public class JdbcUtil {
static{
try{
Class.forName("com.mysql.jdbc.driver");
}catch(Exception e)
{
e.printStackTrace();
}
}
public static Connection getConnection()
{
Connection con=null;
try{
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/sms","root","hanzhao1024");
}catch(Exception e){
e.printStackTrace();
}
return con;
} public static void release(Connection con,Statement stmt,ResultSet rs)
{
try{
if(rs!=null)
{
rs.close();
} }catch(Exception e)
{
e.printStackTrace();
}
try{
if(stmt!=null)
{
stmt.close();
} }catch(Exception e)
{
e.printStackTrace();
}
try{
if(con!=null)
{
con.close();
} }catch(Exception e)
{
e.printStackTrace();
} }
public static void printRs(ResultSet rs)
{
StringBuffer sb=new StringBuffer();
try{
while(rs.next())
{
sb.append("id="+rs.getInt(1)+"");
sb.append("name="+rs.getString(2)+"\n");
}
System.out.println(sb.toString()); }catch(Exception e)
{
e.printStackTrace();
} } }

JdbcUtil

4)数据访问层接口StudentDao

 package com.chapter11.dao;

 import java.sql.SQLException;
import java.util.List;
import java.sql.SQLException; import com.chapter11.bean.Student; public interface StudentDao {
public void insertStudent(Student stu)throws SQLException;
public List queryAllStudents()throws SQLException; }

StudentDao

5)数据访问层接口实现类StudentDaoImpl

 package com.chapter11.dao;

 import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import com.chapter11.bean.Student;
import com.chapter11.util.JdbcUtil; public class StudentDaoImpl implements StudentDao { Connection con=null;
public StudentDaoImpl(Connection con)
{
this.con=con;
}
PreparedStatement pstmt=null;
ResultSet rs=null;
public void insertStudent(Student stu)throws SQLException
{
String sql="insert into student(name,birthday) value(?,?)";
pstmt=con.prepareStatement(sql);
pstmt.setString(1, stu.getName());
pstmt.setDate(2, stu.getBirthday());
pstmt.executeUpdate();
JdbcUtil.release(null, pstmt, null);
}
public List queryAllStudents()throws SQLException
{
String sql="select*from student";
List students=new ArrayList();
pstmt=con.prepareStatement(sql);
ResultSet rs=pstmt.executeQuery();
while(rs.next())
{
Student stu=new Student();
stu.setId(rs.getInt("id"));
stu.setName(rs.getString("name"));
stu.setBirthday(rs.getDate("birthday"));
students.add(stu);
}
JdbcUtil.release(null, pstmt, null);
return students;
} }

StudentDaoImpl

6)增加和删除的业务服务层接口StudentService

package com.chapter11.service;

import java.sql.SQLException;
import java.util.List; import com.chapter11.bean.Student; public interface StudentService {
public void addStudent(Student stu)throws SQLException;
public List findAllStudent()throws SQLException; }

StudentService

7)增加和删除的业务服务层接口StudentServiceImpl

 package com.chapter11.service;

 import java.sql.Connection;
import java.sql.SQLException;
import java.util.List; import com.chapter11.bean.Student;
import com.chapter11.dao.StudentDao;
import com.chapter11.dao.StudentDaoImpl;
import com.chapter11.util.JdbcUtil; public class StudentServiceImpl implements StudentService{
public void addStudent(Student stu)throws SQLException
{
Connection con=JdbcUtil.getConnection();
try{
con.setAutoCommit(false);
StudentDao sdao=new StudentDaoImpl(con);
sdao.insertStudent(stu);
con.commit(); }catch(Exception e)
{
e.printStackTrace();
} }
public List findAllStudent()throws SQLException {
Connection con=JdbcUtil.getConnection();
List students=null;
try{
con.setAutoCommit(false);
StudentDao sdao=new StudentDaoImpl(con);
sdao.queryAllStudents();
con.commit(); }catch(Exception e)
{
e.printStackTrace();
} return students;
} }

StudentServiceImpl

8)Web层控制器Servlet

package com.chapter11.servlet;

import java.io.IOException;
import java.sql.Date;
import java.util.List; import javax.servlet.RequestDispatcher;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import com.chapter11.bean.Student;
import com.chapter11.service.*; @WebServlet("/SMSServletController")
public class SMSServletController extends HttpServlet {
private static final long serialVersionUID = 1L; public SMSServletController() {
super(); } protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
this.doPost(request, response);
} protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
StudentService ss=new StudentServiceImpl();
String path=request.getServletPath();
path=path.substring(0,path.indexOf("."));
if(path.equalsIgnoreCase("/sms/list"))
{
try
{
List students=ss.findAllStudent();
request.setAttribute("students", students);
forward("list.jsp",request,response); }catch(Exception e)
{
throw new ServletException("error when query!");
}
}else if(path.equalsIgnoreCase("/sms/add"))
{
request.setCharacterEncoding("UTF-8");
String name=request.getParameter("name");
String birthday=request.getParameter("birthday");
Student student=new Student();
student.setBirthday(Date.valueOf(birthday));
student.setName(name);
try{
ss.addStudent(student); }catch(Exception e)
{
e.printStackTrace();
}
response.sendRedirect(request.getContextPath()+"/sms/list.do");
} } private void forward(String url, HttpServletRequest request,
HttpServletResponse response)throws IOException,ServletException{
ServletContext application=getServletContext();
RequestDispatcher ds=application.getRequestDispatcher(url);
ds.forward(request,response); } }

Servlet

9)Web层表示页面

整个过程即为一个基本的MVC设计模式以及代码流程。在此还未解决的问题是最后的表示层页面显示,会在此后逐步解决。

web初学之MVC的更多相关文章

  1. YbSoftwareFactory 代码生成插件【二十一】:Web Api及MVC性能提升的几个小技巧

    最近在进行 YbSoftwareFactory 的流程功能升级,目前已经基本完成,现将用到的一些关于 Web Api 及 MVC 性能提升的一些小技巧进行了总结,这些技巧在使用.配置上也相当的简单,但 ...

  2. Atitit.web三大编程模型 Web Page Web Forms 和 MVC

    Atitit.web三大编程模型 Web Page    Web Forms 和 MVC 1. 编程模型是 Web Forms 和 MVC (Model, View, Controller). 2.  ...

  3. Atitit.web三编程模型 Web Page Web Forms 和 MVC

    Atitit.web三编程模型 Web Page    Web Forms 和 MVC 1. 编程模型是 Web Forms 和 MVC (Model, View, Controller). 2. W ...

  4. java web 初学

    我希望在本学期本堂课上学会使用java web 框架 精通mvc架构模式 学会通过框架和数据库对产品进行构造与编写. 我计划每周用16小时的时间进行学习java web 一周4学时上课时间 周一到周五 ...

  5. PHP做Web开发的MVC框架(Smarty使用说明 )

    PHP做Web开发的MVC框架(Smarty使用说明 ) 一.Smarty简明教程 1.安装演示 下载最新版本的Smarty-3.1.12,然后解压下载的文件.接下来演示Smarty自带的demo例子 ...

  6. SpringMVC内容略多 有用 熟悉基于JSP和Servlet的Java Web开发,对Servlet和JSP的工作原理和生命周期有深入了解,熟练的使用JSTL和EL编写无脚本动态页面,有使用监听器、过滤器等Web组件以及MVC架构模式进行Java Web项目开发的经验。

    熟悉基于JSP和Servlet的Java Web开发,对Servlet和JSP的工作原理和生命周期有深入了解,熟练的使用JSTL和EL编写无脚本动态页面,有使用监听器.过滤器等Web组件以及MVC架构 ...

  7. 用maven创建web项目(spring Mvc)

    用maven创建web项目(spring Mvc) 1.打开cmd进入到你要创建maven项目的目录下: 2.输入以下命令.然后根据提示输入相应的groupId.artifactId.version: ...

  8. Java Web开发中MVC设计模式简介

    一.有关Java Web与MVC设计模式 学习过基本Java Web开发的人都已经了解了如何编写基本的Servlet,如何编写jsp及如何更新浏览器中显示的内容.但是我们之前自己编写的应用一般存在无条 ...

  9. [译]Create a Web API in MVC 6

    原文: http://www.asp.net/vnext/overview/aspnet-vnext/create-a-web-api-with-mvc-6 ASP.NET 5.0的一个目标是合并MV ...

随机推荐

  1. android学习笔记57——电话管理器TelephoneyManager

    电话管理器TelephoneyManager

  2. Map以及Set的遍历(EntrySet方法,补充enumeration和Iterator的区别)

    public void mearge(Map map) { Map returnMap = new HashMap<>(); // 转换为Entry Set<Map.Entry< ...

  3. (C#) 使用Nullable类型

    有个case,对一个double数设置初始值,然后,在程序运行中,为double赋值.(注意,也可能没有赋值). 这个时候,可以用Nullable 来设置初始值,在程序的最后做个判断. 参考:

  4. SSH配置免密码登陆

    1.使用SSH-keygen,然后一路回车使之生成id_rsa何id_rsa.pub文件,id_rsa.pub为公匙文件. 2.使用命令:cat ~/.ssh/id_rsa.pub >> ...

  5. jsp Request获取url信息的各种方法比较

    从Request对象中可以获取各种路径信息,以下例子: 假设请求的页面是index.jsp,项目是WebDemo,则在index.jsp中获取有关request对象的各种路径信息如下 String p ...

  6. 2015.05.12:json的常用处理方式

    1:json的介绍:json常用于前台与后台的数据传输  传递时需将json对象转换为json字符 JSON.stringify(); 2:json格式的查看应用:JsonView 3:后台获取到js ...

  7. mac系统下Ruby环境安装

    在我们编写代码过程中,会用到一系列的第三方开源类库,我们可以选择手动去一个个添加需要的库,但这非常麻烦.因此我们可以使用CocoaPods来帮助我们自动添加.使用CocoaPods需要先安装Ruby环 ...

  8. 如何启动另一个应用的activity

    1.使用action Intent i=new Intent(); i.setAction(".........."); startActivity(i); 前提条件:要启动的ac ...

  9. 安卓基于WifiScanner的签到APP

    没图说个JB?首先上图:      友情提醒:后台数据库使用的是Bmob后端云 主要设计思路:首先选一个附近的wifi,输入签到码,进行签到. 签到之后会启动一个后台线程每隔一段时间扫描附近wifi, ...

  10. 1o_Samba

    ∮Linux下Samba的安装配置 §Linux 下文件共享软件 Samba 是一款实现跨主机,跨平台文件共享的软件.同类型的软件还有 ftp,nfs 不再赘述. §文件共享协议 Windows : ...