jsp增删改查2.docx
- 文档编号:23356057
- 上传时间:2023-05-16
- 格式:DOCX
- 页数:8
- 大小:15.60KB
jsp增删改查2.docx
《jsp增删改查2.docx》由会员分享,可在线阅读,更多相关《jsp增删改查2.docx(8页珍藏版)》请在冰豆网上搜索。
jsp增删改查2
Webroot文件夹下:
Index.Jsp
<%@pagelanguage="java"import="java.util.*"pageEncoding="utf-8"%>
DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML4.01Transitional//EN">
=null?
request.getAttribute("msg"):
""%>
请输入登陆信息
姓名:
=null? request.getAttribute("username_reg"): ""%>"/> 密码 login_pro.jsp <%@pagelanguage="java"contentType="text/html;charset=utf-8"pageEncoding="utf-8"%> <%@pageimport="com.king.bean.UserInfo"%> <%@pageimport="com.king.dao.UserDao"%> <%@pageimport="com.king.dao.UserDaoImpl"%> <% Stringusername=request.getParameter("username"); Stringpassword=request.getParameter("password"); request.setAttribute("username_reg",newString(username.getBytes("iso-8859-1"),"utf-8")); if(username==null||username.trim().equals("")){ request.setAttribute("msg","用户名不能为空! "); request.getRequestDispatcher("index.jsp").forward(request,response); }elseif(password==null||password.trim().equals("")){ request.setAttribute("msg","密码不能为空! "); request.getRequestDispatcher("index.jsp").forward(request,response); }else{ UserInfou=newUserInfo(); u.setUsername(newString(username.getBytes("iso-8859-1"),"utf-8")); u.setPassword(newString(password.getBytes("iso-8859-1"),"utf-8")); UserDaodao=newUserDaoImpl(); booleanflag=dao.loginUser(u); if(flag==true){ request.setAttribute("username",u.getUsername()); request.getRequestDispatcher("userList_pro.jsp").forward(request,response); }else{ request.setAttribute("msg","登陆信息有误,请再次登陆或注册! "); request.getRequestDispatcher("index.jsp").forward(request,response); } } %> <%@pagelanguage="java"contentType="text/html;charset=utf-8"pageEncoding="utf-8"%> <%@pageimport="com.king.bean.UserInfo"%> <%@pageimport="com.king.dao.UserDao"%> <%@pageimport="com.king.dao.UserDaoImpl"%> <% Stringusername=request.getParameter("username"); Stringpassword=request.getParameter("password"); request.setAttribute("username_reg",newString(username.getBytes("iso-8859-1"),"utf-8")); if(username==null||username.trim().equals("")){ request.setAttribute("msg","用户名不能为空! "); request.getRequestDispatcher("index.jsp").forward(request,response); }elseif(password==null||password.trim().equals("")){ request.setAttribute("msg","密码不能为空! "); request.getRequestDispatcher("index.jsp").forward(request,response); }else{ UserInfou=newUserInfo(); u.setUsername(newString(username.getBytes("iso-8859-1"),"utf-8")); u.setPassword(newString(password.getBytes("iso-8859-1"),"utf-8")); UserDaodao=newUserDaoImpl(); booleanflag=dao.loginUser(u); if(flag==true){ request.setAttribute("username",u.getUsername()); request.getRequestDispatcher("userList_pro.jsp").forward(request,response); }else{ request.setAttribute("msg","登陆信息有误,请再次登陆或注册! "); request.getRequestDispatcher("index.jsp").forward(request,response); } } register.jsp(注册) <%@pagelanguage="java"import="java.util.*"pageEncoding="utf-8"%> DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML4.01Transitional//EN">
=null?
request.getAttribute("msg"):
""%>
请输入注册信息
姓名:
=null? request.getAttribute("username_reg"): ""%>"/> 密码 register_pro.jsp(注册处理) <%@pagelanguage="java"contentType="text/html;charset=utf-8"pageEncoding="utf-8"%> <%@pageimport="com.king.bean.UserInfo"%> <%@pageimport="com.king.dao.UserDao"%> <%@pageimport="com.king.dao.UserDaoImpl"%> <% Stringusername=request.getParameter("username"); Stringpassword=request.getParameter("password"); request.setAttribute("username_reg",newString(username.getBytes("iso-8859-1"),"utf-8")); if(username==null||username.trim().equals("")){ request.setAttribute("msg","用户名不能为空! "); request.getRequestDispatcher("register.jsp").forward(request,response); }elseif(password==null||password.trim().equals("")){ request.setAttribute("msg","密码不能为空! "); request.getRequestDispatcher("register.jsp").forward(request,response); }else{ UserInfou=newUserInfo(); u.setUsername(newString(username.getBytes("iso-8859-1"),"utf-8")); u.setPassword(newString(password.getBytes("iso-8859-1"),"utf-8")); UserDaodao=newUserDaoImpl(); booleanflag=dao.saveUser(u); if(flag==true){ request.getSession().setAttribute("username",u.getUsername()); request.getRequestDispatcher("userList_pro.jsp").forward(request,response); }else{ request.getRequestDispatcher("register.jsp").forward(request,response); } } %> %> 查看: user_view.jsp <%@pagelanguage="java"contentType="text/html;charset=utf-8"pageEncoding="utf-8"%> <%@pageimport="com.king.bean.UserInfo"%> DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML4.01Transitional//EN">
<%UserInfou=(UserInfo)request.getSession().getAttribute("userInfo_update");%>
collapse;">用户信息用户
<%=u.getId()%>
<%=u.getUsername()%>
<%=u.getPassword()%>
<
userList_pro.jsp列表处理
<%@pagelanguage="java"import="java.util.*"pageEncoding="utf-8"%>
<%@pageimport="com.king.dao.UserDao"%>
<%@pageimport="com.king.dao.UserDaoImpl"%>
<%
UserDaodao=newUserDaoImpl();
ListuserList=dao.fecthUserList();
if(userList!
=null&&userList.size()>0){
request.setAttribute("userList",userList);
request.getRequestDispatcher("userList.jsp").forward(request,response);
}else{
request.setAttribute("msg","目前无用户信息,请注册!
");
request.getRequestDispatcher("register.jsp").forward(request,response);
}
%>
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- jsp 增删
![提示](https://static.bdocx.com/images/bang_tan.gif)