使用MVC模式开发程序,完成数据的模糊查询
编写程序:使用MVC模式开发程序,完成数据的模糊查询。
要求:
(1)index.jsp用于输入要查询的数据。
(2)result.jsp:用于显示结果。
(3)queryServlet:用于验证数据、实例化JavaBean、调用连接数据库、控制页面跳转
(4)queryDAO:用于连接数据库及进行数据库的操作如:查询、删除、更改等
(5)Student:JavaBean用于数据的封装,方便将查询结果在servlet与jsp页面之间进行传递等
以上几个部分共同构成了MVC模式,JSP为MVC模式当中的V,Servlet为C,queryDAO与JavaBean合在一起为M。
[html]
<%@ page language="java" import="java.util.*" pageEncoding="GBK"%> 
<% 
String path = request.getContextPath(); 
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; 
%> 
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 
<html> 
  <head> 
    <base href="<%=basePath%>"> 
     
    <title>My JSP 'index.jsp' starting page</title> 
    <meta http-equiv="pragma" content="no-cache"> 
    <meta http-equiv="cache-control" content="no-cache"> 
    <meta http-equiv="expires" content="0">     
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> 
    <meta http-equiv="description" content="This is my page"> 
    <!--
    <link rel="stylesheet" type="text/css" href="styles.css">
    --> 
  </head> 
   
  <body> 
    请输入要查询的内容: 
    <form action="queryServlet" method="post"> 
    <input name="name"> 
    <input type="submit" value="模糊查询"> 
    </form> 
  </body> 
</html> 
[html]
<%@ page language="java" import="java.util.*,com.mars.*" pageEncoding="gb2312"%> 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 
<html> 
<head> 
    <title>查询结果</title> 
</head> 
<body> 
   查询结果如下: 
   <table border="1"> 
   <tr> 
        <td>学号</td> 
	
相关新闻>>
- 发表评论
- 
				
- 最新评论 进入详细评论页>>


