zoukankan      html  css  js  c++  java
  • ff

    /**
     * Servlet
     */
    sun公司提供的开发动态web资源的Java类
    交互式地浏览和修改数据,生成动态Web内容
    运行环境是服务器环境
    接收请求
    完成响应
    /**
     * 新建Servlet项目
     */
    Package
    New
    Web Project
    New
    Class
    cn.wewezhang.weServlet
    package cn.wewezhang.weServlet;
    import java.io.IOException;
    import javax.servlet.Servlet;
    import javax.servlet.ServletConfig;
    import javax.servlet.ServletException;
    import javax.servlet.ServletRequest;
    import javax.servlet.ServletResponse;
    public class WeServlet implements Servlet{
    	@Override
    	public void init(ServletConfig arg0) throws ServletException {
    		System.out.print("WeServlet - init");
    	}
    	@Override
    	public void service(ServletRequest arg0, ServletResponse arg1) throws ServletException, IOException {
    		System.out.print("WeServlet - service");
    		arg1.getWriter().write("写点什么好呢");
    	}
    	@Override
    	public void destroy() {
    		System.out.print("WeServlet - destroy");
    	}
    	@Override
    	public ServletConfig getServletConfig() {
    		// TODO Auto-generated method stub
    		return null;
    	}
    	@Override
    	public String getServletInfo() {
    		// TODO Auto-generated method stub
    		return null;
    	}
    }
    //web.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns="http://java.sun.com/xml/ns/javaee"
        xmlns:xsi="http://www/w3.org/2001/XMLSchema-instance"
        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>
        	<servlet-name>WeServlet</servlet-name>
        	<servlet-class>cn.wewezhang.weServlet</servlet-class>
        </servlet>
        
        <!-- Servlet的路径 -->
        <servlet-mapping>
        	<servlet-name>WeServlet</servlet-name>
        	<url-pattern>/WeServlet</url-pattern>
        </servlet-mapping>
        
        
        <welcome-file-list>
            <welcome-file>index.jsp</welcome-file>
        </welcome-file-list> 
    </web-app>
    //
    http://localhost:8080/WeServlet/WeServlet
    

      

  • 相关阅读:
    性能测试相关概念
    java -json()
    jquery ajax 前前后后,所有的函数并查询链接
    jquery ajax get /post
    jquery ajax load
    三个重要属性
    发送请求
    处理返回结果(XML)
    处理返回结果
    调用对象
  • 原文地址:https://www.cnblogs.com/WeWeZhang/p/6785098.html
Copyright © 2011-2022 走看看