我的JSP页面:
<%@ page language="java" import="java.util.*" pageEncoding="gb2312"%>
<%@ page import="DBHandle.DBConn" %>
<%@ page import="java.sql.*" %>
<%
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>
</head>
<body>
<div style="z-index:0;position:absolute;left:15px;top:5px;color:red";>
<font size=4> 公司介绍:</font><br>
重要提醒:贵公司的资料上网后会受到其他客户及工商质检部门等多方关注,请如实填写!<br>
因此虚假信息产生的相关责任,将由贵公司自行承担 (只能创建一个公司!)
</div>
<div style="z-index:0;position:absolute;left:15px;top:80px";>
<form action="Company_Servlet" method="post" enctype="multipart/form-data" id="form1" name="form" onsubmit="return check()">
<table width="750px" height=570px border=1 align=center cellpadding=2 cellspacing=0 style="word-break:break-all;" >
<caption align=left><font color=red>公司资料(带*号的为必须添)</font></caption>
<tr>
<td width="25%" align="right">公司名称:</td>
<td width="30%" >
<input name="companyName" id="NameId" type="text" size="20" maxlength="50" ></td>
<td width="45%"><font color=red>*</font>(请用中文完整填写在共商局注册的公司全称!)</td>
</tr>
<tr>
<td align="right">公司类型:</td>
<td>
<select name="companyType" style="width:155px";>
<option value="1">个体经营 </option>
<option value="2">私营企业 </option>
<option value="3">国有企业 </option>
<option value="4">股份公司 </option>
<option value="5">中外和资 </option>
</select>
</td>
<td><font color=red>*</font></td>
</tr>
<tr>
<td align="right">主营产品:</td>
<td>
<select name="mainProduct" style="width:155px";>
<option value="1">服装</option>
<option value="2">数码电子</option>
<option value="3">化装用品</option>
<option value="4">书籍/音响</option>
<option value="5">装饰品</option>
</select>
</td>
<td><font color=red>*</font>(请认真选择,会决定你发布的东西在哪类!)</td>
</tr>
<tr>
<td align="right">创立时间:</td>
<td><input name=createTime id="createTime" type="text" size=20 maxlength=16></td>
<td><font color=red>*</font>(你现有公司创立的年份,如:2004!)</td>
</tr>
<tr>
<td colspan="3" align=center><input type=submit value="提交"><input type=reset value="重置"></td>
</tr>
</table>
</form>
</div>
<script language='Javascript'>
function check(){
if(document.form.companyName.value==""){
alert("请填写公司名称!");
return false;
}
if (document.form.createTime.value==""){
alert("请填写创立时间!");
return false;
}
}
</script>
</body>
</html>
我的SERVLET:
package myServlet;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class Company_Servlet extends javax.servlet.http.HttpServlet implements
javax.servlet.Servlet{
/**
*
*/
private static final long serialVersionUID = 5196096313704409848L;
public Company_Servlet(){
super();
}
public void doPost(HttpServletRequest request,HttpServletResponse response) throws
ServletException,IOException{
response.setContentType("text/html;charset=gb2312");
String method=request.getParameter("method");
String mycompanyName=request.getParameter("companyName");
String mycompanyType=request.getParameter("companyType");
String mymainProduct=request.getParameter("mainProduct");
String mycreateTime=request.getParameter("createTime");
String myprovince=request.getParameter("province");
String mycity=request.getParameter("city");
System.out.print(request.getParameter("companyName"));
System.out.print(mymainProduct);
}
public void doGet(HttpServletRequest request,HttpServletResponse response) throws
ServletException,IOException{
doPost(request,response);
}
}
我的WEB.XML
<servlet>
<servlet-name>companyInfo</servlet-name>
<servlet-class>myServlet.Company_Servlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>companyInfo</servlet-name>
<url-pattern>/Company_Servlet</url-pattern>
</servlet-mapping>
当我提交的时候,怎么打印出来的全是NULL啊,我添写了啊,不为空啊,怎么了啊?
哪位大哥帮帮看看,谢谢!!!
在线等..