当前位置: 代码迷 >> Java Web开发 >> 一小疑点!但很长!代码也违反了MVC 但..
  详细解决方案

一小疑点!但很长!代码也违反了MVC 但..

热度:42   发布时间:2016-04-17 15:16:40.0
一小问题!但很长!代码也违反了MVC 但..
我有个html页面如下: <!DOCTYPE   html   PUBLIC   "-//W3C//DTD   XHTML   1.0   Transitional//EN "   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html   xmlns= "http://www.w3.org/1999/xhtml ">
<head>
<meta   http-equiv= "Content-Type "   content= "text/html;   charset=gb2312 "   />
<title> 无标题文档 </title>
</head>

<body>
<form   id= "form1 "   name= "form1 "   method= "post "   action= "dcservlet.java ">
    <p>                                               软件插入数据库 </p>
    <p> 姓   名:                                        
        <input   type= "text "   name= "name "   />
    </p>
    <p> 密   码:
        <input   type= "text "   name= "password "   />
    </p>
    <p> 地   址:  
        <input   type= "text "   name= "address "   />
    </p>
    <p> 联系电话:
        <input   type= "text "   name= "tel "   />
    </p>
    <p> &nbsp; </p>
    <p>
 
        <input   type= "submit "   name= "Submit "   value= "提交 "   />
 
 
        <input   type= "reset "   name= "Submit2 "   value= "重置 "   />
   
    </p>
   
</form>
</body>
</html>


  把这个值传递给一个servlet 如下

package   model;

import   java.io.*;
import   javax.servlet.http.*;
import   java.util.*;
import   java.sql.*;

import   javax.servlet.*;


public   class   dcservlet   extends   HttpServlet   {
                private   static   final   String   CONTENT_TYPE= "text/html;charset=GBK ";
                private   String   comeOutStr= " ";
                private   int   comeOutInt=0;
                private   static   Connection   con;
                private   Statement   stmt;
                  private   static   final   String   drivername= "org.gjt.mm.mysql   Driver ";
                  private   static   final   String   url= "jdbc:mysql://localhost/zqswork02?user=root&password=root&useUnicode=true&characterEncoding=gb2312 ";
                  public   static   Connection   getCon()   throws   Exception   {
  相关解决方案