JavaEE-Servlet的部署和配置
1、:配置好相应环境和检查tomcat8.5能否运行,详见https://www.cnblogs.com/LJHAHA/p/10461697.html
2、将tomcat8.5下的webapps目录中所有内容备份到另一文件夹(bak)中,再清空webapps目录;
3、进入eclipse,配置好相应环境后,进入Servers,点击下方红色圈处,将tomcat8.5集成到eclipse中;

4.选择新建一个Apache下的Tomcat v8.5 Server--->Finish

5.双击红色圈出的Tomcat v8.5 Server at localhost,进入上方的设计页面,其余的不做更改,需要将Server Locations改选为第二项Use Tomcat installation,同时检查下方路径是否正确,最好将Deploy path改为tomcat8.5下自带的webapps,最后别忘了点击保存;

6.新建一个Dynamic Web Project(名为prj1),在Java Resources->src目录下新建一个包,名为edu.lsnu.first,在该包下新建一个HelloServlet类,编辑以下内容;
package edu.lsnu.first; import java.io.IOException;
import java.io.PrintWriter; import javax.servlet.Servlet;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse; public class HelloServlet implements Servlet{ public static void main(String[] args) {
} @Override
public void destroy() {
} @Override
public ServletConfig getServletConfig() {
return null;
} @Override
public String getServletInfo() {
return null;
} @Override
public void init(ServletConfig arg0) throws ServletException {
} @Override
public void service(ServletRequest request, ServletResponse response) throws ServletException, IOException {
response.setContentType("text/html;charset=utf-8");
PrintWriter out = response.getWriter();
out.print("<h1>欢迎光临</h1>");
out.close();
} }
7.接下来,再进入web->MEB_INF目录下,点开web.xml文件,编辑以下内容;
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" id="WebApp_ID" version="3.1">
<display-name>prj1</display-name>
<servlet>
<servlet-name>HelloServlet</servlet-name>
<servlet-class>edu.lsnu.first.HelloServlet</servlet-class>
</servlet> <servlet-mapping>
<servlet-name>HelloServlet</servlet-name>
<url-pattern>/hello</url-pattern>
</servlet-mapping> <welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
编译器的最终布局显示如下:

8.点击Tomcat v8.5 Server at localhost,右键选择Add and Remove...,将项目prj1添加到Tomcat中来;

9.启动服务器;

成功后会显示下图情况


10.最后在浏览器中输入http://127.0.0.1:8080/prj1/hello或http://localhost:8080/prj1/hello,回车即可出现网页

JavaEE-Servlet的部署和配置的更多相关文章
- servlet(二):Servlet的web.xml配置
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http:// ...
- servlet中web.xml配置
常见的Servlet中url-pattren的配置 1.固定配置, 如:/hi 引入通配符 * 2.以"/XXX"开头,以"*"结尾 3.以"*&qu ...
- Tigase XMPP Server在CentOS部署和配置
Tigase XMPP Server在CentOS部署与配置 作者:chszs,转载需注明.博客主页:http://blog.csdn.net/chszs 以下讲述Tigase XMPP Server ...
- web缓存服务器varnish-4.1.6的部署及配置详解
web缓存服务器varnish-4.1.6的部署及配置详解 1.安装varnish4.1.6安装依赖 yum install -y autoconf automake jemalloc-devel l ...
- 【转】mysql8.0 在window环境下的部署与配置
[转]mysql8.0 在window环境下的部署与配置 今天在阿里云window服务器上配置mysql环境,踩了一些坑,分享出来.需要的朋友可以看看.额,或许有人要吐槽我为什么不在linux上去配置 ...
- Zookeeper集群部署与配置(三)
在上一篇博客中我们讲解了<Zookeeper的单机配置>,此篇博客将继续介绍Zookeeper的集群部署与配置. 环境 集群配置的环境与单机配置的环境相同,唯一不同的就是集群是在多台服务器 ...
- (原创)OpenStack服务如何使用Keystone (二)---部署和配置Keystone中间件
(一)Keystone端的操作 (二)如何在OpenStack服务上部署Keystone中间件 (三)详细配置keystonemiddleware 部署OpenStack时一般先安装Keystone服 ...
- Storm 系列(三)Storm 集群部署和配置
Storm 系列(二)Storm 集群部署和配置 本章中主要介绍了 Storm 的部署过程以及相关的配置信息.通过本章内容,帮助读者从零开始搭建一个 Storm 集群. 一.Storm 的依赖组件 1 ...
- Tomcat6.0下的jsp、servlet和javabean的配置
第一步:下载jdk和tomcat: 第二步:安装和配置你的jdk和tomcat:执行jdk和tomcat的安装程序,然后设置按照路径进行安装即可.1.安装jdk以后,需要配置一下环境变量,在我的电脑- ...
- Office Online Server 2016 部署和配置
Office Online Server 2016 部署和配置https://wenku.baidu.com/view/65faf8de846a561252d380eb6294dd88d1d23d45 ...
随机推荐
- 【进阶3-4期】深度解析bind原理、使用场景及模拟实现(转)
这是我在公众号(高级前端进阶)看到的文章,现在做笔记 https://github.com/yygmind/blog/issues/23 bind() bind() 方法会创建一个新函数,当这个新函 ...
- FormData中delete方法在ios不兼容
1.移动端直接用的input的file上传图片(name=“file”必填) <input type="file" id="exampleInputFile1&qu ...
- "字体arial不支持样式regular"的解决方法
软件报错,提示“字体arial不支持样式regular”的提示,这是由于字体arial缺失导致的, “字体arial不支持样式regular”的解决方法如下: 方法/步骤 1.用户需要先下载arial ...
- js操作数组元素
一, 删除数组指定的某个元素 首先可以给JS的数组对象定义一个函数,用于查找指定的元素在数组中的位置,即索引,代码为: Array.prototype.indexOf = function(val) ...
- PDF如何设置书签,怎么在PDF上添加书签
PDF文件现在作为我们使用最多的一种办公文件,当然我们在使用PDF文件的同时还会需要编辑PDF文件,在使用一个PDF文件页数比较多的时候就需要添加书签,不然每次使用的时候都需要从头开始查找是很麻烦又头 ...
- python之路第二天
为何要有操作系统 为了让程序员更轻松的完成命令电脑工作而存在的,控制硬件,服务于软件. 操作系统的位置 操作系统位于软件和硬件之间.操作系统由内核(运行于内核态,控制硬件)和系统调用(运行于用户态,为 ...
- 使用vue-cli 引入bootstrap.min.css文件报错
可以在index.html 里面引入boostrap.min.css文件 将bootstrap.min.css文件放置于static/css/文件夹中 然后再index.html文件中引入便可 < ...
- Java+selenium之WebDriver对浏览器的简单操作(一)
操作浏览器的主要方法都来自 org.openqa.selenium.WebDriver 这个接口 这些方法都是在 org.openqa.selenium.remote.RemoteWebDriver这 ...
- 让Mysql支持Emoji表情,解决[Err] 1366 - Incorrect string value: '\xF0\xA3\x84\x83'
mysql insert内容包含表情或者unicode码时候,插入Mysql时失败了,报如下异常: java.sql.SQLException: Incorrect string value: '\x ...
- shell 写的 jrottenberg/ffmpeg 转码
#!/bin/bash ];then echo "The argument must be 2" exit; else echo "$1 $2" fi VIDE ...