将 XML 数据导入 Google App Engine
2010-10-22 17:18:53 来源:WEB开发网清单 5. 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_2_5.xsd" version="2.5">
<servlet>
<servlet-name>CreateEmployeeServlet</servlet-name>
<servlet-class>com.xmlimport.servlet.CreateEmployeeServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>CreateEmployeeServlet</servlet-name>
<url-pattern>/CreateEmployee</url-pattern>
</servlet-mapping>
</web-app>
清单 6 展示了这个 servlet。
清单 6. CreateEmployeeServlet.java
package com.xmlimport.servlet;
import java.io.IOException;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.xmlimport.employee.EmployeeHandler;
public class CreateEmployeeServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
new EmployeeHandler();
PrintWriter out = response.getWriter();
out.println(“Employees Created”);
}
}
更多精彩
赞助商链接