用户注册(request,get和post中文乱码)
来源:互联网 发布:php中面向对象的机制有 编辑:程序博客网 时间:2024/06/05 11:19
<!DOCTYPE html><html><head><meta charset="UTF-8"><title>注册</title><script type="text/javascript" src="jquery-3.2.1.js"></script><script>$(function() {var cities = [ [ "西安", "咸陽" ], [ "鄭州", "商丘" ], [ "石家莊", "唐山" ],[ "昆明", "麗江" ] ];var city = $("#city");$("#pro").change(function() {$("#city option:gt(0)").remove();var val = $(this).val();$(cities).each(function(i, n) {if (i == val) {$(n).each(function(j, cit) {city.append("<option>" + cit + "</option>");})}})})})</script><script>$(function() {$(".required").each(function() {$(this).parent().append("<b style='color: red'>*</b>");})$("form input").blur(function() {var parent = $(this).parent();$(parent).find("b").remove();if ($(this).is("#username")) {if ($(this).val() == "") {$(this).parent().append("<b class='error' style='color: red'>用户名不能为空</b>");} else {$(this).parent().append("<b style='color: green'>用户名正确</b>");}}if ($(this).is("#password")) {if ($(this).val() == "") {$(this).parent().append("<b class='error' style='color: red'>密码不能为空</b>");} else {$(this).parent().append("<b style='color: green'>密码正确</b>");}}}).keyup(function(){$(this).triggerHandler("blur");}).focus(function(){$(this).triggerHandler("blur");})$("form").submit(function() {$("form input").trigger("blur");var err = $(".error").length;if (err > 0) {return false;}})})</script><style type="text/css" contenteditable="inherit">div {width: 100%;}#bodydiv {width: 90% px;}.logodiv {width: 33%;float: left;height: 48px;}.clear {clear: both;}.cd {background-color: black;height: 30px;}</style></head><body><div id="bodydiv"><div class="logodiv"><img alt="" src="../imag/head1.png" height=100%></div><div class="logodiv"><img alt="" src="../imag/head2.png" height=100%></div><div class="logodiv"style="padding-top: 5px; text-align: center; height: 43px"align="center"><a href="#">登陆</a> <a href="zhuce.html">注册</a> <a href="#">购物车</a></div><div class="clear"></div><div class="cd"><a href="shouyediv.html">首页</a> <a href="#">手机数码</a> <a href="#">电脑办公</a><a href="#">研烟酒箱包</a></div><divstyle="height: 800px; background-image: url('../imag/zhuce.jpg'); background-size: 100% 100%;"><divstyle=" height:90%;position: absolute;top: 300px;"align="left"><form method="post" action="/J2EE/registservlet"><table align="center" border="0" width=40%><tr><td align="right" width=50%>用户名 <td align="left"><input class="required" type="text"name="username" id=username></input></td></tr><tr><td align="right" width=50%>密码 <td align="left"><input class="required" type="password"name="password" id="password"></input></tr><tr><td align="right" width=50%>确认密码 <td align="left"><input class="required" type="password"name="repassword"></input><span id="repassword"></span></td></tr><tr><td align="right" width=50%>邮箱 <td align="left"><input type="text" name="email"></input></td></tr><tr><td align="right" width=50%>性别 <td align="left"><input type="radio" name="sex" value="man"checked="checked">男<input type="radio" name="sex"value="woman">女</td></tr><tr><td align="right" width=50%>生日 <td align="left"><input type="date" name="birth"></td></tr><tr><td align="right" width=50%>爱好 <td align="left"><input type="checkbox" name="love"value="1">看电视<input type="checkbox" name="love"value="2">打游戏<input type="checkbox" name="love"value="3">吃饭<input type="checkbox" name="love" value="4"checked>睡觉</td></tr><tr><td align="right" width=50%>籍贯 <td align="left"><select id="pro" name="pro"><option>--请选择--<option value="0">陕西<option value="1">河南<option value="2">河北<option value="3">云南</select> <select name="city" id="city"><option>--请选择--</select><tr><td align="right" width=50%>头像 <td align="left"><input type="file"></td></tr><tr><td align="right" width=50%>个人简介 <td align="left"><textarea cols="" rows="5" name="a">我是一个</textarea></td></tr><tr><td colspan="2" align="center"><input type="submit"value="注册 " id="sub"><input type="reset" value="重置"></td></tr></table></form></div></div><div><img alt="" src="../imag/q.png" width="100%"></div><div style="text-align: center;"><a href="html.html">关于我们</a> 公司简介 招贤纳士 广告服务 联系方式 合作伙伴 论坛反馈<br>版权声明:Copyright© 1999-2016,赵瑾的网站 , All Rights Reserved</div></div></body></html>
package regist;import java.io.IOException;import java.io.PrintWriter;import java.sql.SQLException;import javax.servlet.ServletException;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;public class registservlet extends HttpServlet {private static final long serialVersion=1L;public void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {//1.接收参数String username = request.getParameter("username");String password = request.getParameter("password");//2.封装参数User user=new User();user.setUsername(username);user.setPassword(password);//3.调用业务层处理数据userservice us=new userservice();try {us.regist(user);} catch (SQLException e) {// TODO Auto-generated catch blocke.printStackTrace();}//4.页面跳转response.sendRedirect("/J2EE/html/login.html");}public void doPost(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException {doGet(request, response);}}
package regist;public class User {private Integer id;public Integer getId() {return id;}public void setId(Integer id) {this.id = id;}public String getUsername() {return username;}public void setUsername(String username) {this.username = username;}public String getPassword() {return password;}public void setPassword(String password) {this.password = password;}private String username;private String password;}
package regist;import java.sql.SQLException;public class userservice {/* * 业务层注册用户的方法 */public void regist(User user) throws SQLException{userdao ud=new userdao();ud.regist(user);}}
package regist;import java.sql.SQLException;import org.apache.commons.dbutils.QueryRunner;import utils.c3p0tool;public class userdao {public void regist(User user) throws SQLException{QueryRunner qr=new QueryRunner(c3p0tool.getDataSource());String sql="insert into user values(null,?,?)";qr.update(sql,user.getUsername(),user.getPassword());}}
阅读全文
0 0
- 用户注册(request,get和post中文乱码)
- request.getParameter()在get和post方法中文乱码问题
- request的get请求和post请求的中文乱码问题
- request的中文乱码get、post处理方式
- request乱码问题,post和get乱码调整
- Servlet开发GET和POST中文乱码处理(原创)
- jsp中文乱码问题(get和post)
- post和get请求中文乱码解决方案
- GET和POST中文乱码的解决方法
- get,post中文乱码
- get中文乱码/post
- $GET $POST 和 $REQUEST
- Get,Post和Request
- request的get和post参数乱码问题
- Post 提交中文乱码问题和GET提交乱码问题
- javaweb之request乱码解决(数据提交以post方式和get方式)
- Spring get/post 中文乱码
- post/get解决中文乱码
- 继承和多态
- jQuery的Chaining方法
- java常用正则表达式
- bzoj 4408 [Fjoi 2016]神秘数 主席树
- JS无缝滚动
- 用户注册(request,get和post中文乱码)
- java寻找迷宫路径
- 关闭”xx程序已停止工作”提示窗口
- MyEclipse配置
- android studio 最新3.0 kotlin与databinding 结合使用报错。
- H5 js中的localStorage与sessionStorage
- MySQL和Oracle差异
- unity编辑器扩展--AssetBundle菜单
- python matplotlib画图