首页 新闻 会员 周边 捐助

eclipse下创建web工程 写一个servlet?

0
[待解决问题]

谁能给我写一个实例啊  我自己写的 请求页面不响应

麻烦能教我写一个规范点的么 这个eclipse不怎么会用也

问题补充:

/**
* Servlet implementation class OneServlet
*/
public class OneServlet extends HttpServlet {
private static final long serialVersionUID = 1L;

/**
* @see HttpServlet#HttpServlet()
*/
public OneServlet() {
super();
// TODO Auto-generated constructor stub
}

/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
}

/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

PrintWriter out = response.getWriter();
out.println("aaa");
}

}

 

//////

web.xml

 

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID"
version="3.0">

<display-name>WebServlet</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>

<servlet>
        <servlet-name>OneServlet</servlet-name>    
        <servlet-class>com.lesta.test.OneServlet</servlet-class>    
    </servlet>

    <servlet-mapping>
        <servlet-name>OneServlet</servlet-name>
        <url-pattern>/OneServlet</url-pattern>   
    </servlet-mapping>
</web-app>

 

可是web报错 

部署完工程 请求也没反应 eclipse创建sevlet 不知道是哪的问题

询问java1的主页 询问java1 | 初学一级 | 园豆:72
提问于:2013-12-23 18:18
< >
分享
所有回答(1)
0

很简单的,创好web工程后,你新建一个servlet。它会自动创建这个类,并帮你写到xml配置文件中的。

angelshelter | 园豆:9914 (大侠五级) | 2013-12-23 22:01
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册