2011/2/21
新建servlet之后出现错误是什么原因?
今天在学旺旺老师的第二课Servlet处理中文乱码,按照视频学习的时候,发现自添加了servlet文件之后,在IE中浏览出现404的错误,如下图
其中有 index.jsp和TestServlet.java两个文件,
Index.jsp
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%
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 'index.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">
-->
</head>
<body>
<form action="TestServlet">
<input name="name">
<input type="submit" value="sumbit">
</form>
</body>
</html>
TestServlet.java
TestServlet.javapackage com.jianson;
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;
public class TestServlet extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String name=request.getParameter("name");
System.out.println("name="+name);
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String name=request.getParameter("name");
System.out.println("name="+name);
}
}
今天还有一件很让人丢脸的事情,就是自己本来是学习网络专业的还不及一个门外汉,今天中午无线路由器出问题了,用线连接无线路由器没问题,但是用笔记本无线连接路由器的时候,却发现IP地址不是公司局域网地址而是路由器自己分配的。因为这台无线路由是放在我旁边的而且我也从设置过它,我总是想着保持默认的设置路由器就没开DHCP服务,而且自己老以为没可能是路由器的错了,后来同事亲自操刀调配无线路由,他发现DHCP服务没关结果把问题给解决了,而且他还告诉了我那个配置DHCP在路由器的哪个选项配置,真的丑大了。