jtahstu的博客

root@jtahstu.com   Github   英文博客  

最新碎语:以后没事写写小的知识点吧

您的位置:jtahstu的博客 >笔记> 大三下软件项目开发实训第八天 - 物流管理系统v2.0

大三下软件项目开发实训第八天 - 物流管理系统v2.0

早上笔记

功能1:添加数据
     第一步:得让子dao支持
         public void insertKhudangan(Kehudangann kh){
         }
     第二步:创建AddServlet调用子dao后,重定向。
     第三步:写前端的form表单。
功能2:登陆
    案例:登陆淘宝网:
       程序如何判定用户登陆成功:
           看你输入的用户名和密码是不是在同一条数据上出现吧!
     第一步:得子到支持。
            public int login(String user_id,String user_pwd){
              String sql="select * from userinfo where user_id='"+user_id+"' and user_pwd='"+user_pwd+"'";
              return super.query(sql).size()>0?1:0;
           }  
     第二步:创建登陆  servlet方法。login.do
     第三步:完善登陆界面
         写form表单和action,method方法。
         第一错:密码框的名称错了。
    第四步:发送登陆请求,点击登陆按钮。action,
        第二个错:serlvet中的doGet没有调用doPost请求。
注意点:在BaseDAO中将语句打印出来。
功能3:修改密码
      第一步:子dao支持
              public void updUserInfo(String user_id,String user_pwd,String newpwd){
                   int flag=1;
                   String sql="select * from userinfo where user_id=? and user_pwd=?";
                  List<UserInfo> list=super.query(sql);
                  if(list.size()>0){
                     String sql="update from userinfo set    where  ";
                     super.update(sql);
                     flag=0;
                 }
                  else{
                      //不能修改
                  }
                  return flag;
              }
      第二步:常见修改密码用的servlet。updpwd.do
      第三步:完善修改信息页面。
      第四步:完善主界面,top.jsp中
功能4:用户登陆成功后,提示欢迎语句。
      技术点:
        request.setAttribute("list",list);--转发给谁,谁才能取到。
        session.setAttribute("list",list);--项目向的所有页面都能取到。
下午的事情:晚上上午的不足之处,修改功能。------jQuery脚本语言中ajax异步请求技术。

昨天回顾

回顾:在框架中的数据显示和数据删除
   显示:
    第一步:创建数据库表和测试数据
    第二步:创建表格对应的bean对象和拷贝jar包
    第三步:创建bean对象对应的子dao。---对该类对象所有的操作。
    第四步:对应的servlet中调用子dao中的方法,并且转发到kehudangan.jsp
    第五步:写show.jsp页面
            <%request.getAttribute("list")%>
             for(){
                 <tr></tr>
               }
   第六步:测试数据,点击客户档案<li><a href="show.do" marget="right"></a></li>
   删除功能:
    第一步:得子dao支持。
       public void delKehudangan(String id){
            String sql="delete from kehudangan where kh_bh='"+id+"'";
            super.update(sql);
         }
    第二步:第四步:对应的servlet中调用子dao中的方法,并且重定向。
      response.sendR...("show.do");
     第三步:完善kehudangan.jsp
           <a href="del.do?kh_bh=<%=list.get(i).getKh_bh()%>"></a>
     第四步:点击删除按钮
            发送请求。
   

下午笔记

异步请求:ajax技术。
案例1:google suggest 异步请求。
   特性:登陆等待时,不能进行其他操作。---同步请求。
案例:填写住址时,二级地址刷新。----省市二级联动。
ajax技术达到的效果是:局部刷新。数据时空上变化。
     作用:就是创建更快,交互性更强的程序。
数据通信技术:json字符串
    格式;{"id":"1001","name":"汤晓春","sex":"1"}
          {"":"","":""}
          有专门的方式去解析json字符串。
    需求:将集合中的所有对象都变成字符串。
          [{"":"","":""},{"":"","":""},{"":"","":""}]
通过a标签发送请求是的格式:
     add.do?id="1001"&name="tangxiaochun"&sex="1"
表单序列化$("#from1").serialize(),
     加工厂:add.do?kh_bh=1001&name=躺下春&sex=1&
jQuery框架下的ajax技术。
如何实现用户使用异步请求添加数据。
第一步:引入jQuery包。
   jQuery是啥?是一门可以在外部操作html元素的技术。
     动态的改变html的属性或者值。
    <script type="text/javascript" src="js/jquery-1.8.0.min.js"></script>
第二步:给按钮写上点击方法
     <input type="submit" class="right_button01"  onclick="add()" value="添加" name="btt"/>
第三步:写add方法。
       function add(){
       }
第四步:在add方法中写异步请求
    $.ajax({
            type:"post",
            url:"add.do",
            cache:false,
            data:$("#form1").serialize(),
            success:function(){
              alert("=======2=====");
            }
         });
第五步:测试:
      点击添加按钮测试。
修改用户信息:
  第一步:将修改的那只青色笔,加上去,然后写上,onclick="jiazai()"
  第二步:写jiazai这个方法。
  第三步:写异步请求
         $.ajax({
             type:"post",
             url:"jiazai.do",
             cache:false,
             data:{"kh_bh":id},
             success:function(){
                alert("=======2=====");
            }
          });
   第四步:创建子dao
    public List<Kehudangan> findByBh(String id){
       String sql="select * from kehudangan where kh_bh='"+id+"'";
       return super.query(sql);
      }
   第五步:创建servlet---jiazai.do
               String kh_bh=request.getParameter("kh_bh");
  List<Kehudangan> list=new KehudanganDAO().findByBh(kh_bh);
  String str=List2json2.obj2jsonArr(list);
     //将值返回给前端的success方法---回调函数。
  response.getWriter().print(str); 
  第六步:解析json字符串--在前端解析。
         eval("kehu="+msg);
                var bh=kehu[0].kh_bh;
                var bm=kehu[0].kh_bm;
                var mc=kehu[0].kh_mc;
                var jc=kehu[0].kh_jc;
                var dh=kehu[0].kh_dh;
                var dz=kehu[0].kh_dz;
                var lxr=kehu[0].kh_lxr;
                var email=kehu[0].kh_email;
                var cz=kehu[0].kh_cz;
  第七步:将值付给文本框。
       //将值赋给文本框
                $("#kh_bh").val(bh);
                $("#kh_bm").val(bm);
                $("#kh_mc").val(mc);
                $("#kh_jc").val(jc);
                $("#kh_dh").val(dh);
                $("#kh_dz").val(dz);
                $("#kh_lxr").val(lxr);
                $("#kh_email").val(email);
                $("#kh_cz").val(cz);
  第八步:给修改按钮写onclick方法
  第九步:写upd方法。
     upd()
   第十步:写异步请求方法:
      function upd(){
       $.ajax({
            type:"post",
            url:"upd.do",
            cache:false,
            data:$("#form1").serialize(),
            success:function(msg){
            }
         });}
   第十一步:创建子dao
public void updKehudangan(Kehudangan kh){
       String sql="update kehudangan set kh_bm='"+kh.getKh_bm()+"',kh_mc='"+kh.getKh_mc()+"',kh_jc='"+kh.getKh_jc()+"',kh_dh='"+kh.getKh_dh()+"',kh_dz='"+kh.getKh_dz()+"',kh_lxr='"+kh.getKh_lxr()+"',kh_email='"+kh.getKh_email()+"',kh_cz='"+kh.getKh_cz()+"' where kh_bh='"+kh.getKh_bh()+"'";
          super.update(sql);
      }
   第十二步:写upd.doservlet

kehudangan.jsp

<%@page import="com.it.bean.Kehudangan"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
 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 'kehudangan.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">
 -->
<script type="text/javascript" src="js/jquery-1.8.0.min.js"></script>
<script type="text/javascript">
 //表格隔行变色
      $(function(){
        $("#tb1 tr:odd").css("background-color","#eeeeee");
        $("#tb1 tr:even").css("background-color","white");
        $("#tr1").css("background-color","#6795b4");
      });
      //鼠标移到行上,行变色
     $(function(){
         $("#tb1 tr").bind("mousemove",function(){
         $(this).css("background-color","#6795b4");
         $("#tr1").css("background-color","#6795b4");
       });
         $("#tb1 tr").bind("mouseout",function(){
         $("#tb1 tr:odd").css("background-color","#eeeeee");
         $("#tb1 tr:even").css("background-color","white");
         $("#tr1").css("background-color","#6795b4");
       });
       //鼠标移动到超链接上,超链接变色
       $("a").bind("mousemove",function(){
           $(this).css("color","red");
         }); 
       //鼠标离开超链接上,超链接恢复颜色
       $("a").bind("mouseout",function(){
           $(this).css("color","#1b8ff2");
         }); 
        $("#upd").bind(); 
       });
       function add(){
       alert("===你在使用ajax添加数据====");
         $.ajax({
            type:"post",
            url:"add.do",
            cache:false,
            data:$("#form1").serialize(),
            success:function(){
              alert("=======2=====");
            }
         });
       }
       function jiazai(id){
          $.ajax({
             type:"post",
             url:"jiazai.do",
             cache:false,
             data:{"kh_bh":id},
             success:function(msg){
                alert("=======2====="+msg);
                //将json字符串转换成了数组
                eval("kehu="+msg);
                var bh=kehu[0].kh_bh;
                var bm=kehu[0].kh_bm;
                var mc=kehu[0].kh_mc;
                var jc=kehu[0].kh_jc;
                var dh=kehu[0].kh_dh;
                var dz=kehu[0].kh_dz;
                var lxr=kehu[0].kh_lxr;
                var email=kehu[0].kh_email;
                var cz=kehu[0].kh_cz;
                //将值赋给文本框
                $("#kh_bh").val(bh);
                $("#kh_bm").val(bm);
                $("#kh_mc").val(mc);
                $("#kh_jc").val(jc);
                $("#kh_dh").val(dh);
                $("#kh_dz").val(dz);
                $("#kh_lxr").val(lxr);
                $("#kh_email").val(email);
                $("#kh_cz").val(cz);
            }
          });
       }
       function upd(){
       $.ajax({
            type:"post",
            url:"upd.do",
            cache:false,
            data:$("#form1").serialize(),
            success:function(msg){
            alert(msg);
               if(msg==1){
                 alert("==恭喜哥,修改成功!==");
               }
            }
         });}
 </script>
<style type="text/css">
body {
 margin: 0px;
}
#tb1 {
 border: #666666;
 width: 1175px;
 border: 1px solid #464646;
 border-collapse: collapse;
}
#tb2 {
 width: 918px;
 border: 1px;
}
#tb1 tr td {
 border: 1px;
 border-color: #464646;
 border-collapse: collapse;
 border-style: solid;
}
#tr1 {
 background-color: #6795b4;
 height: 30px;
 font-size: 18px;
}
#tr1 td {
 color: #FFFFFF;
}
#tr2 {
 background: #eeeeee;
 text-align: center;
}
#tr1 td {
 color: #FFFFFF;
}
#tr2 {
 background: #eeeeee;
 text-align: center;
}
a {
 text-decoration: none;
}
</style>
</style>
</head>
<body>
<%
   List<Kehudangan> list=(List<Kehudangan>)request.getAttribute("khlist");
 %>
 <img alt="" src="images/righttopbanner1.jpg">
 <table id="tb1">
  <tr id="tr1">
   <td height="25" colspan="10"><div align="center">客户档案</div>
   </td>
  </tr>
  <tr id="tr2">
   <td>客户编号</td>
   <td>客户编码</td>
   <td>客户名称</td>
   <td>客户简称</td>
   <td>客户电话</td>
   <td>操作</td>
  </tr>
  <%for(int i=0;i<list.size();i++){ %>
   <tr>
    <td><%=list.get(i).getKh_bh() %></td>
    <td><%=list.get(i).getKh_bm() %></td>
    <td><%=list.get(i).getKh_mc() %></td>
    <td><%=list.get(i).getKh_jc() %></td>
    <td><%=list.get(i).getKh_dh() %></td>
     <td>
        <a href="del.do?kh_bh=<%=list.get(i).getKh_bh() %>">删除</a>
        <img title="修改" src="image/upd.png" onclick="jiazai(<%=list.get(i).getKh_bh() %>)">
     </td> 
   </tr>
   <%} %>
 </table>
 <form id="form1" method="post" > 
  <table id="tb2" align="center">
   <tr>
    <td width="131"><div align="right">客户编号:</div>
    </td>
    <td width="180"><input type="text" name="kh_bh" id="kh_bh" />
    </td>
    <td width="93"><div align="right">客户编码:</div>
    </td>
    <td width="182"><input type="text" name="kh_bm" id="kh_bm" />
    </td>
    <td width="113"><div align="right">客户名称:</div>
    </td>
    <td width="179"><input type="text" name="kh_mc" id="kh_mc" />
    </td>
   </tr>
   <tr>
    <td><div align="right">客户简称:</div>
    </td>
    <td><input type="text" name="kh_jc" id="kh_jc" />
    </td>
    <td><div align="right">客户电话:</div>
    </td>
    <td><input type="text" name="kh_dh" id="kh_dh" />
    </td>
    <td><div align="right">客户地址:</div>
    </td>
    <td><input type="text" name="kh_dz" id="kh_dz" />
    </td>
   </tr>
   <tr>
    <td><div align="right">客户联系人:</div>
    </td>
    <td><input type="text" name="kh_lxr" id="kh_lxr" />
    </td>
    <td><div align="right">客户邮箱:</div>
    </td>
    <td><input type="text" name="kh_email" id="kh_email" />
    </td>
    <td><div align="right">客户传真:</div>
    </td>
    <td><input type="text" name="kh_cz" id="kh_cz" />
    </td>
   </tr>
   <tr>
    <td height="10"></td>
   </tr>
   <tr align="center">
    <td colspan="6">
        <input type="submit" class="right_button01"  onclick="add()" value="添加" name="btt"/>
     <input type="submit" class="right_button01" value="修改" onclick="upd()" name="btt" />
     <input type="submit" class="right_button01" value="查询" name="btt" />
        <input type="submit" class="rigth_button01" value="删除" name="btt" />
    </td>
   </tr>
  </table>
         </form>
</body>
</html>

AddServlet.java

package com.it.servlet;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.it.bean.Kehudangan;
import com.it.dao.KehudanganDAO;
public class AddServlet extends HttpServlet {
 public AddServlet() {
  super();
 }
 public void destroy() {
  super.destroy(); // Just puts "destroy" string in log
  // Put your code here
 }
 public void doGet(HttpServletRequest request, HttpServletResponse response)
   throws ServletException, IOException {
  doPost(request, response);
 }
 public void doPost(HttpServletRequest request, HttpServletResponse response)
   throws ServletException, IOException {
  System.out.println("===============1===================");
  String bh=request.getParameter("kh_bh");
  String bm=request.getParameter("kh_bm");
  String mc=request.getParameter("kh_mc");
  String jc=request.getParameter("kh_jc");
  String dh=request.getParameter("kh_dh");
  String dz=request.getParameter("kh_dz");
  String lxr=request.getParameter("kh_lxr");
  String email=request.getParameter("kh_email");
  String cz=request.getParameter("kh_cz");
  Kehudangan kh=new Kehudangan(bh,bm,mc,jc,dh,dz,lxr,email,cz);
     new KehudanganDAO().insertKehudangan(kh);
     //Öض¨Ïòµ½show.do
     response.sendRedirect("show.do");
 }
 public void init() throws ServletException {
  // Put your code here
 }
}

JiaZaiServlet.java

package com.it.servlet;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.it.bean.Kehudangan;
import com.it.dao.KehudanganDAO;
import com.it.util.List2json2;
public class JiaZaiServlet extends HttpServlet {
 /**
  * Constructor of the object.
  */
 public JiaZaiServlet() {
  super();
 }
 /**
  * Destruction of the servlet. <br>
  */
 public void destroy() {
  super.destroy(); // Just puts "destroy" string in log
  // Put your code here
 }
 /**
  * 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 {
  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 {
  String kh_bh=request.getParameter("kh_bh");
  List<Kehudangan> list=new KehudanganDAO().findByBh(kh_bh);
  String str=List2json2.obj2jsonArr(list);
     //将值返回给前端的success方法---回调函数。
  response.getWriter().print(str);
 }
 /**
  * Initialization of the servlet. <br>
  *
  * @throws ServletException if an error occurs
  */
 public void init() throws ServletException {
  // Put your code here
 }
}

UpdPwdServlet.jsp

package com.it.servlet;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.it.dao.UserInfoDAO;
public class UpdPwdServlet extends HttpServlet {
 /**
  * Constructor of the object.
  */
 public UpdPwdServlet() {
  super();
 }
 /**
  * Destruction of the servlet. <br>
  */
 public void destroy() {
  super.destroy(); // Just puts "destroy" string in log
  // Put your code here
 }
 /**
  * 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 {
  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 {
  System.out.println("=================2=================");
  String user_id=request.getParameter("user_id");
  String user_pwd=request.getParameter("user_pwd");
  String newpwd=request.getParameter("newpwd");
  //调用子dao中的修改密码方法   
  int flag=new UserInfoDAO().updUserInfo(user_id, user_pwd, newpwd);
  if(flag==0){
   response.setHeader("refresh", "5;url=login.jsp");
  }
  else{
   //提醒用户错误信息
   request.setAttribute("message","信息有误,无权修改");
   request.getRequestDispatcher("updpwd.jsp").forward(request, response);
  }
 }
 /**
  * Initialization of the servlet. <br>
  *
  * @throws ServletException if an error occurs
  */
 public void init() throws ServletException {
  // Put your code here
 }
}

updServlet.java

package com.it.servlet;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.it.bean.Kehudangan;
import com.it.dao.KehudanganDAO;
public class UpdServlet extends HttpServlet {
 /**
  * Constructor of the object.
  */
 public UpdServlet() {
  super();
 }
 /**
  * Destruction of the servlet. <br>
  */
 public void destroy() {
  super.destroy(); // Just puts "destroy" string in log
  // Put your code here
 }
 /**
  * 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 {
  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 {
  System.out.println("===============1===================");
  request.setCharacterEncoding("utf-8");
  response.setContentType("text/html;charset=utf-8");
  String bh=request.getParameter("kh_bh");
  String bm=request.getParameter("kh_bm");
  String mc=request.getParameter("kh_mc");
  String jc=request.getParameter("kh_jc");
  String dh=request.getParameter("kh_dh");
  String dz=request.getParameter("kh_dz");
  String lxr=request.getParameter("kh_lxr");
  String email=request.getParameter("kh_email");
  String cz=request.getParameter("kh_cz");
  Kehudangan kh=new Kehudangan(bh,bm,mc,jc,dh,dz,lxr,email,cz);
  int flag=1;
  try {
   new KehudanganDAO().updKehudangan(kh);
  } catch (Exception e) {
   flag=0;
  }
  //写一个参数给ajax。
  response.getWriter().print(flag);
 }
 /**
  * Initialization of the servlet. <br>
  *
  * @throws ServletException if an error occurs
  */
 public void init() throws ServletException {
  // Put your code here
 }
}

list2json.java

package com.it.util;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.List;
/**
 *将一个集合利用反射转成Json的数据格式 
 * 
 *@author  孙军
 *2015年6月3日 上午11:20:40
 */
public class List2json2 {
     public static String obj2json(Object obj){
      @SuppressWarnings("rawtypes")
  Class clz=obj.getClass();
      Method[] methods=clz.getDeclaredMethods();
      StringBuffer sb=new StringBuffer();
      sb.append("{");
      int k=0;
      for(int i=0;i<methods.length;i++){
          Method m=methods[i];
          String mName=m.getName();
          if(m.getModifiers()==Modifier.PUBLIC&&mName.startsWith("get")){
           String attrName=mName.substring(3).toLowerCase();
           String  attrValue="";
           try {
      attrValue=(m.invoke(obj)==null?"":m.invoke(obj)).toString();
    } catch (Exception e) {
     e.printStackTrace();
    } 
           if(k!=0){
            sb.append(",");
           }
//           String json="{\"total\":"+stolist.size()+",\"rows\":"+JSONArray.fromObject(pagelist)+"}";
           sb.append("\""+attrName+"\":"+"\""+attrValue+"\"");
           k++;
          }
      }
      sb.append("}");
      return sb.toString();
     }
     public static String obj2jsonArr(@SuppressWarnings("rawtypes") List list){
      StringBuffer sb=new StringBuffer();
      sb.append("[");
      for(int i=0;i<list.size();i++){
       if(i!=0){
        sb.append(",");
       }
       sb.append(obj2json(list.get(i)));
      }
      sb.append("]");
      return sb.toString();
     }
//     public static void main(String [] args){
//      B b=new B("牢记吧","施华样","溜达鸡巴");
//      String st=List2json.obj2json(b,"str");
//      System.out.println(st);
////      st.getBytes(charset)
////         st.substring(0, endIndex)
//      char[] chars=st.toCharArray();
//      String str1=new String(chars);//通过构造器将字符数组转换成字符串
//      String str2=new String(chars,1,chars.length-2);//截取第一个字符到第五个字符。通过构造器将字符数组转换成字符串
//       System.out.println(str2);
//       String[] strs2=str2.split(",");
//       List<String> list=new ArrayList<>();
//       for (String s : strs2) {
//       // System.out.println(s);
//        String[] strs3=s.split(":");
//        for (String string : strs3) {
//   String a=string.substring(1, string.length()-1);
//   System.out.println(a);
//   list.add(a);
//   
//  }
//    }
//     }
}

updpwd.jsp

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
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>修改密码</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="updpwd.do" method="post">
              用户名:<input type="text"  name="user_id"/><br/>
             老密码:<input type="text"  name="user_pwd"/><br/>
             新密码:<input type="text"  name="newpwd"/><br/>
             <input type="submit" value="修改"/>
             <input type="reset" value="重置"/>
    </form>
  </body>
</html>

---

本文章采用 知识共享署名2.5中国大陆许可协议 进行许可,欢迎转载,演绎或用于商业目的。

---

二维码加载中...

扫一扫移动端访问O(∩_∩)O

发表评论

86 + 95 =
路人甲 表情
看不清楚?点图切换 Ctrl+Enter快速提交
正在加载中……