标题:jsp求助,为什么文件里写了一个submit的value=“登录”但显示“提交查询内容 ...
只看楼主
jxpchenfeng
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2010-10-30
结帖率:0
已结贴  问题点数:5 回复次数:4 
jsp求助,为什么文件里写了一个submit的value=“登录”但显示“提交查询内容”
文件里写了一个submit的value=“登录”但显示“提交查询内容”
急寻求助啊
搜索更多相关主题的帖子: jsp value submit 登录 提交查询内容 
2010-10-30 01:26
ghjsmzy
Rank: 7Rank: 7Rank: 7
等 级:黑侠
威 望:1
帖 子:187
专家分:573
注 册:2009-6-17
得分:1 
应该是乱码了吧!把jsp贴出来看下吧!
2010-10-30 22:29
jxpchenfeng
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2010-10-30
得分:0 
程序代码:
<%@ page language="java" import="java.util.*,java.sql.*,javax.sql.DataSource" pageEncoding="GB2312"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%
request.setCharacterEncoding("GB2312");
if(request.getParameter("username")!=null)
    {
        Connection conn = null;
        Statement smt = null;
        ResultSet rs = null;
        try
        {       
            Class.forName("com.mysql.jdbc.Driver");
        }
        catch(ClassNotFoundException e)
        {
            out.print(e.getMessage());
        }
        try{
            System.out.println("iiii");
            conn = DriverManager.getConnection("jdbc:MySql://localhost:3306/web?user=root&password=123&useUnicode=true&characterEncoding=gb2312");
            smt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
            String sql = "insert into user values('"+(String)request.getParameter("username")+"','"+ (String)request.getParameter("password") +"','"+(String)request.getParameter("email")+"','')";
            smt.executeUpdate(sql);       
        }catch(SQLException e)
        {
            e.printStackTrace();
        }catch(Exception e)
        {
            e.printStackTrace();
        }finally{
            try{
                if(rs!=null)
                {
                    rs.close();       
                }
                if(smt!=null)
                {
                    smt.close();
                }
                if(conn!=null)
                {
                    conn.close();
                }
            }catch(Exception e)
            {
                e.printStackTrace();
            }
        }
    }
    %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
   
    <title>My JSP 'regist.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">

  </head>

 
  <body>
    <form method="post" name="f1" action="regist.jsp">
   <h1 align="center">注册</h1><div align="center"><br>
   </div><div align="center"><div align="center">用户名:
      <input type="text" name="username" size="20" maxlength="20"><br><br>密码:
      <input type="password" name="password" size="20" maxlength="20"><br><br>邮箱:
      <input type="text" name="email" size="20" maxlength="20"><br></div>
      <input type="submit" name="Regist" value="注册 " onClick="validateLogin()";>
   </div>

 </form>

 <script language="javaScript">
     function validateLogin()
     {
      var sUserName = document.f1.username.value;
      var sPassword = document.f1.password.value;
      var sEmail = document.f1.email.value;



      if( sUserName=="" )
      {
       alert("请输入用户名!");
       return false;
      }
      if( sPassword=="" )
      {
       alert("请输入密码!");
       return false;
      }
      if( sEmail=="" )
      {
       alert("请输入邮箱!");
       return false;
      }
      if(sUserName.length<6)
      {
           alert("用户名请不小于6个字符!  ");
           return false;
      }
      if(sPassword.length<6)
      {
           alert("密码请不小于6个字符! ");
           return false;
      }
    
           var reg = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;
      if(!reg.test(sEmail))
      {
          alert("邮箱格式错误 ! ");
           return false;
      }            
     }
     </script>
  </body>
</html>
代码
2010-10-31 14:00
maxliz
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:版主
威 望:5
帖 子:71
专家分:248
注 册:2010-8-22
得分:1 
<input type="submit" name="Regist" value="注册 " onClick="validateLogin()";>
 onClick="validateLogin()去掉
然后form method="post" name="f1" action="regist.jsp" onsubmit=xxxxxxxxxxxxxx
2010-11-02 23:01
qingzhu5753
Rank: 4
等 级:业余侠客
帖 子:64
专家分:248
注 册:2009-10-28
得分:1 
<input type="submit" name="Regist" value="注册 " onClick="validateLogin()";>
改成 <input type="submit" value="注册 " onClick="validateLogin()";>
就好了!!!
2010-11-03 13:54



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-324432-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.175362 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved