package controllers;
import java.io.IOException;
import java.sql.*;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import models.se;
/**
* 这个类的作用主要是起到一个控制转发的功能 根据用户提交请求的action来分别调用不同的方法来处理不同的action
*/
public class Controller extends HttpServlet
{
//用户无论是通过get或者是post提交的请求都会转到doPost来处理
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
this.doPost(request, response);
}
/**
* doPost方法 用户提交的请求都由这个方法来处理
*/
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
{
//对用户提交的请求用utf-8来解码,否则会出现乱码
se workM=new se();
request.setCharacterEncoding("utf-8");
//获取用户请求的资源路径
String actionurl = request.getServletPath();
//根据用户提交请求资源路径不同调用不同的方法处理
if (actionurl.equals("/Login.action"))
{
String logname = request.getParameter("username");
String logpass = request.getParameter("password");
String sql="select * from user where username='"+logname+"' and password='"+logpass+"'";
try
{
ResultSet rs=workM.executeQuery(sql);
if(rs.next())
{
response.sendRedirect(request.getContextPath() + "/views/success.jsp");
}
else
{
response.sendRedirect(request.getContextPath() + "/views/lost.jsp");
}
}
catch(SQLException e)
{
e.printStackTrace();
}
}
else if (actionurl.equals("/registerInfo.action"))
{
response.sendRedirect(request.getContextPath() + "/views/info.jsp");
}
}
}
javaweb+MVC+64位win7 jdbc连接access
需积分: 7 24 浏览量
2014-03-14
22:27:10
上传
评论
收藏 522KB ZIP 举报
liulangren7
- 粉丝: 0
- 资源: 3
最新资源
- 基于MIC+NE555光敏电阻的声光控电路Multisim仿真原理图
- python tkinter-08-盒子模型.ev4.rar
- Doozy UI Manager 2023
- 基于matlab实现夜间车牌识别程序(1).rar
- 基于matlab实现无线传感器网络无需测距定位算法matlab源代码 包括apit,dv-hop,amorphous在内的共7个
- 基于python的yolov5实现的旋转目标检测
- 基于matlab实现无线传感器网络 CAB定位仿真程序 这是无线传感器节点定位CAB算法的仿真程序,由matlab完成.rar
- 基于matlab实现图像处理,本程序使用背景差分法对来往车辆进行检测和跟踪.rar
- 基于matlab实现视频监控中车型识别代码,自己写的,希望和大家多多交流.rar
- springcodespringcodespringcodespringcode
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈