Create web and an overview of the servlet

http://www.xinhuanet.com/fortune/2019-12/07/c_1125318193.htm

URL: http: //www.xinhuanet.com/fortune/2019-12/07/c_1125318193.htm (entire-network path)
URI: /fortune/2019-12/07/c_1125318193.htm (native path)

http request mode:
GET:
POST:
the Delete:
PUT:
head:
Connect:
the trace:
Options:
Here Insert Picture Description
Here Insert Picture Description

web server :
Tomcat
Ø the Apache
Ø Jboss
Ø IIS (platform-specific window)
Ø Weblogic
Ø Nginx

Tomcat:
Download: official website (Apache)

配置(不是必须的):
	JAVA_HOME:Java安装的主路径
	CATALINA_HOME: tomcat的主路径
	path追加 %CATALINA_HOME%\bin;%JAVA_HOME%\bin;

测试:
	cmd
	1、startup
	2、catalina start
tomcat目录结构:
	|-- tomcat名称				//apache-tomcat-8.0.21
		|-- bin				// 功能命令
		|-- logs			// 保存日志
		|-- conf			// 配置文件
			|-- context.xml
			|-- server.xml
			|-- web.xml
			|-- tomcat-users.xml
		|-- lib				// java web需要的jar包
		|-- temp			// 临时文件夹
		|-- work			// 编译后字节码文件(不要动)
		|-- webapps			// 部署项目的文件夹
			|-- 项目名称
				|-- xx.html
				|-- css
				|-- img
				|-- js
				|-- xxxx
				|-- WEB-INF
					|-- web.xml
					|-- classes
					|-- lib
eclipse-jee的安装和下载
	https://www.eclipse.org/downloads/packages/
	官网  下载压缩
	在解压完成后,建议添加配置文件中:
		-Dfile.encoding=utf-8

	

	
	
web项目的结构:
	|-- 项目名称
		|-- java source
			|-- src			// java代码
		|-- webConent
			|-- xx.html
			|-- css
			|-- img
			|-- js
			|-- xxxx
			|-- WEB-INF
				|-- web.xml
				|-- classes
				|-- lib	

Here Insert Picture Description

package mypro0.com.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class Mysrevlet extends HttpServlet {
	
	
	private static final long serialVersionUID = 1L;
	/**
	 * doGet方法专门处理get请求的方法
	 */
       @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    	
    	this.doPost(req, resp);
    }
       /**
   	 * doPost方法专门处理postget请求的方法
   	 */
       @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    	
    	System.out.println("hellow sevrlet");
    }
}

Published 162 original articles · won praise 9 · views 3120

Guess you like

Origin blog.csdn.net/ll_j_21/article/details/103941995