tomcat实战案例:手动的应用部署

实战案例:手动的应用部署

1、一个主页目录下的部署应用文件 test.jsp

[root@centos8 tomcat]#vim webapps/ROOT/test.jsp
[root@centos8 tomcat]#cat webapps/ROOT/test.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>jsp例子</title>
</head>
<body>
后面的内容是服务器端动态生成字符串,最后拼接在一起
<%
out.println("hello jsp");
%>
</body>
</html>

[root@centos8 tomcat]#curl http://127.0.0.1:8080/test.jsp

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>jsp例子</title>
</head>
<body>
后面的内容是服务器端动态生成字符串,最后拼接在一起
hello jsp

</body>
</html>

[root@centos8 tomcat]#tree work/Catalina/localhost/ROOT/
work/Catalina/localhost/ROOT/
└── org
    └── apache
        └── jsp
            ├── test_jsp.class
            └── test_jsp.java

3 directories, 2 files
[root@centos8 tomcat]#

2、手动部署一个子目录的应用

[root@centos8 tomcat]#pwd
/usr/local/tomcat
[root@centos8 tomcat]#mkdir webapps/testapp1/

#利用之前实验的文件生成新应用
[root@centos8 tomcat]#cp -p webapps/ROOT/test.jsp  webapps/testapp1/
[root@centos8 tomcat]#chown -R tomcat.tomcat webapps/testapp1/
[root@centos8 tomcat]#tree webapps/testapp1/
webapps/testapp1/
└── test.jsp

0 directories, 1 file
[root@centos8 tomcat]#curl http://127.0.0.1:8080/testapp1/test.jsp

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>jsp例子</title>
</head>
<body>
后面的内容是服务器端动态生成字符串,最后拼接在一起
hello jsp

</body>
</html>[root@centos8 tomcat]#tree work/Catalina/localhost/testapp1/
work/Catalina/localhost/testapp1/
└── org
    └── apache
        └── jsp
            ├── test_jsp.class
            └── test_jsp.java

3 directories, 2 files
[root@centos8 tomcat]#

#删除应用
[root@centos8 tomcat]#rm -rf webapps/testapp1/
[root@centos8 tomcat]#ls webapps/
docs  examples  host-manager  manager  ROOT
[root@centos8 tomcat]#ls work/Catalina/localhost/
docs  examples  host-manager  manager  ROOT

本文链接:http://www.yunweipai.com/35135.html

原创文章,作者:kepupublish,如若转载,请注明出处:https://blog.ytso.com/52739.html

(0)
上一篇 2021年8月6日
下一篇 2021年8月6日

相关推荐

发表回复

登录后才能评论