package ser;
import impl.StudentImpl;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import pojo.Student;
/*
* 在JSP中,Ser它的作用是控制层 也就是获取前台的数据,并且把数据提交给业务逻辑层
*
* Ser起着桥梁的作用 它符合MVC设计模式
*
* V: view 视图 所有的JSP页面 :功能:显示数据 获取数据
*
* C: control: 控制层 功能:获取视图层的数据,并且调用业务逻辑类
*
* M: Model: 负责数据录入 和业务逻辑的实现
*
* */
public class StudentSer extends HttpServlet {
/**
* Constructor of the object.
*/
public StudentSer() {
super();
System.out.println("----StudentSer-----");
}
/**
* Destruction of the servlet. <br>
*/
/* Ser 销毁的时候调用此方法 */
public void destroy() {
super.destroy(); // Just puts "destroy" string in log
// Put your code here
System.out.println("----destory----");
}
/**
* The doGet method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to get.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
this.doPost(request, response);
}
/**
* The doPost method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to post.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.setCharacterEncoding("utf-8");
StudentImpl studentImpl=new StudentImpl();
Student student=new Student();
student.setSname(request.getParameter("sname"));
student.setSaddress(request.getParameter("saddress"));
String[] slikes=request.getParameterValues("slikes");
student.setSlikes(studentImpl.joinString(slikes));
studentImpl.saveStudent(student);
}
/**
* Initialization of the servlet. <br>
*
* @throws ServletException if an error occurs
*/
// 初始化的方法,会在构造方法之后调用
public void init() throws ServletException {
// Put your code here
System.out.println("---init----");
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
jsp的MVC设计模式
共19个文件
java:4个
class:4个
mymetadata:1个
需积分: 15 10 下载量 176 浏览量
2013-01-04
21:57:05
上传
评论
收藏 280KB RAR 举报
温馨提示
web项目开发的MVC设计模式的教程源码,MVC设计模式的思想,上课教程的源代码
资源推荐
资源详情
资源评论
收起资源包目录
02_MVC设计模式_上课源码.rar (19个子文件)
02_MVC设计模式_上课源码
.settings
org.eclipse.wst.jsdt.ui.superType.name 6B
org.eclipse.wst.jsdt.ui.superType.container 49B
.jsdtscope 500B
org.eclipse.jdt.core.prefs 330B
src
db
DBConn.java 1KB
pojo
Student.java 503B
ser
StudentSer.java 3KB
impl
StudentImpl.java 1KB
.project 1KB
WebRoot
META-INF
MANIFEST.MF 36B
WEB-INF
web.xml 751B
classes
db
DBConn.class 2KB
pojo
Student.class 891B
ser
StudentSer.class 2KB
impl
StudentImpl.class 2KB
lib
jtds-1.2.jar 279KB
index.jsp 1KB
.mymetadata 282B
.classpath 433B
.myeclipse
共 19 条
- 1
资源评论
xiaoshuizhu_dashuidi
- 粉丝: 0
- 资源: 4
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功