JAVA WEB1——初始JAVAWEB
2021/7/18 11:07:44
本文主要是介绍JAVA WEB1——初始JAVAWEB,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
JAVA WEB1——初始JAVAWEB
JavaWeb主要指使用Java语言进行动态Web资源开发技术的统称,是解决相关Web互联网领域的技术总和
1、Http协议
- HTTP协议(HyperText Transfer Protocol,超文本传输协议)是由W3C(万维网联盟)组织制定 的一种应用层协议,是用来规范浏览器与Web服务器之间如何通讯的数据格式,主要涉及浏览器 的发请求格式和服务器的响应格式
- HTTP协议通常承载于TCP协议之上,而承载于TLS或SSL协议层之上的协议就是常说的HTTPS协 议
- HTTP默认的端口号为80,HTTPS默认的端口号为443
1.1、Http请求格式
请求行 请求类型 请求的路径 协议的版本(1.1) 请求头 主机 请求长度 请求的浏览器相关信息 空白行 (一个空行) 请求体 也叫请求数据,可以添加任意的其他数据
POST /task01_demo01/demo1.html HTTP/1.1 Host: localhost:8088 Content-Length: 21 Cache-Control: max-age=0 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) name=scott&pwd=123456
1.2、Http响应数据
响应行 协议的版本(1.0 1.1) 状态码 (200 成功 404 路径错误 500 服务错误) 状态信息 响应头 说明客户端要使用的一些附加信息,格式(key:value) 空白行 (一个空行) 响应体 服务器返回给客户端的文本信息
2、Tomcat
2.1、下载
Tomcat官网https://tomcat.apache.org/download-90.cgi
Tomcat 百度云:https://pan.baidu.com/s/1iEEptTiPXPLls3wBpSUg1g提取码:gv2h
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-d2TVQrAT-1626572780953)(http://m.qpic.cn/psc?/V54CA0n72MKGGb0pfLXF4OTqRY0DGvXI/ruAMsa53pVQWN7FLK88i5ppGCramJEjTYRYKirLRt8gxxq1gURFk7A6CDikIzseE5MaO4BFiZzuYECY10u2C1PTrUQ4uLxjCptvUHcM68Wo!/b&bo=gAcGBIAHBgQDCSw!&rf=viewer_4)]
解压到想安装的目录
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-iWZIiwce-1626572780956)(http://m.qpic.cn/psc?/V54CA0n72MKGGb0pfLXF4OTqRY0DGvXI/ruAMsa53pVQWN7FLK88i5ozXp5J8ODXgQOiGzKIjkQPecqPKvaI6qInI3iYhMIBZ9qht4HOl3Z8zcmV35lMeyOMDQ6oqOCfGpLTcTYtiKjw!/b&bo=gAc4BIAHOAQDCSw!&rf=viewer_4)]
添加环境变量
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-qZ8Imomj-1626572780959)(http://m.qpic.cn/psc?/V54CA0n72MKGGb0pfLXF4OTqRY0DGvXI/ruAMsa53pVQWN7FLK88i5ppGCramJEjTYRYKirLRt8goZ192BvnYdHzp.XolRm4PYQlf2k7.kHf4pbOlvVykP1HRwNtO1J89K5.cq1DRoCc!/b&bo=gAc4BIAHOAQDCSw!&rf=viewer_4)]
添加CATALINA_BASE变量
CATALINA_BASE D:\apache-tomcat-9.0.31
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-Yv6fFBSx-1626572780962)(http://m.qpic.cn/psc?/V54CA0n72MKGGb0pfLXF4OTqRY0DGvXI/ruAMsa53pVQWN7FLK88i5ppGCramJEjTYRYKirLRt8iT8dYYCyhJwe635S2*1zXLeX0hbKl4QRilbznXdUhFg29MLEBfuP4y0bKuHf7JBrM!/b&bo=gAc4BIAHOAQDCSw!&rf=viewer_4)]
添加CATALINA_HOME变量
CATALINA_HOME D:\apache-tomcat-9.0.31
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-hZ1YDIh3-1626572780964)(http://m.qpic.cn/psc?/V54CA0n72MKGGb0pfLXF4OTqRY0DGvXI/45NBuzDIW489QBoVep5mcQmSby57ateXuhqj1ybHQX1ZEXY.EFO3zx1Z6NmD2tLox408Qrk.R9Qx*WdjhI84aohguKkDcSVuN6XlKyDH154!/b&bo=gAc4BIAHOAQDWXw!&rf=viewer_4)]
添加到PATH变量
%CATALINA_HOME%\bin;%CATALINA_HOME%\lib
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-xflKGCa6-1626572780965)(http://m.qpic.cn/psc?/V54CA0n72MKGGb0pfLXF4OTqRY0DGvXI/ruAMsa53pVQWN7FLK88i5ozXp5J8ODXgQOiGzKIjkQN6s0yCy.bzOepNd0S724RYGXeHT8BELCGVAlwK28mFKl9TA9n9rj7W2uGikbHvrmY!/b&bo=gAc4BIAHOAQDCSw!&rf=viewer_4)]
2.2、卸载
删除目录,变量即可
2.3、启动
双击运行即可
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-o6V7eZKd-1626572780966)(http://m.qpic.cn/psc?/V54CA0n72MKGGb0pfLXF4OTqRY0DGvXI/ruAMsa53pVQWN7FLK88i5gTpZ4HiqFFoabaOcM1u8mXbnyPu7eCdM*aeig4jyysFPk4rQK1p4BHN5GLLiid5rJqGlcjup3pjAycjr9QR3Lc!/b&bo=gAc4BIAHOAQDCSw!&rf=viewer_4)]
2.4、问题
2.4.1、乱码
打开配置文件
apache-tomcat-9.0.31\conf\logging.properties
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-Oy79YcDJ-1626572780967)(http://m.qpic.cn/psc?/V54CA0n72MKGGb0pfLXF4OTqRY0DGvXI/45NBuzDIW489QBoVep5mcWSaX8WTGZXM0ucds5KNjRygeSEV54XWL.oaqUoNcyMo4SAqBuW8yr7A0riNBHMNHKLnLOedq3cjxCWJXOivU!/b&bo=gAc4BIAHOAQDWXw!&rf=viewer_4)]
修改配置
# Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not use this file except in compliance with # the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. handlers = 1catalina.org.apache.juli.AsyncFileHandler, 2localhost.org.apache.juli.AsyncFileHandler, 3manager.org.apache.juli.AsyncFileHandler, 4host-manager.org.apache.juli.AsyncFileHandler, java.util.logging.ConsoleHandler .handlers = 1catalina.org.apache.juli.AsyncFileHandler, java.util.logging.ConsoleHandler ############################################################ # Handler specific properties. # Describes specific configuration info for Handlers. ############################################################ 1catalina.org.apache.juli.AsyncFileHandler.level = FINE 1catalina.org.apache.juli.AsyncFileHandler.directory = ${catalina.base}/logs 1catalina.org.apache.juli.AsyncFileHandler.prefix = catalina. 1catalina.org.apache.juli.AsyncFileHandler.encoding = UTF-8 2localhost.org.apache.juli.AsyncFileHandler.level = FINE 2localhost.org.apache.juli.AsyncFileHandler.directory = ${catalina.base}/logs 2localhost.org.apache.juli.AsyncFileHandler.prefix = localhost. 2localhost.org.apache.juli.AsyncFileHandler.encoding = UTF-8 3manager.org.apache.juli.AsyncFileHandler.level = FINE 3manager.org.apache.juli.AsyncFileHandler.directory = ${catalina.base}/logs 3manager.org.apache.juli.AsyncFileHandler.prefix = manager. 3manager.org.apache.juli.AsyncFileHandler.encoding = UTF-8 4host-manager.org.apache.juli.AsyncFileHandler.level = FINE 4host-manager.org.apache.juli.AsyncFileHandler.directory = ${catalina.base}/logs 4host-manager.org.apache.juli.AsyncFileHandler.prefix = host-manager. 4host-manager.org.apache.juli.AsyncFileHandler.encoding = UTF-8 java.util.logging.ConsoleHandler.level = FINE java.util.logging.ConsoleHandler.formatter = org.apache.juli.OneLineFormatter java.util.logging.ConsoleHandler.encoding = GBK ############################################################ # Facility specific properties. # Provides extra control for each logger. ############################################################ org.apache.catalina.core.ContainerBase.[Catalina].[localhost].level = INFO org.apache.catalina.core.ContainerBase.[Catalina].[localhost].handlers = 2localhost.org.apache.juli.AsyncFileHandler org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].level = INFO org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/manager].handlers = 3manager.org.apache.juli.AsyncFileHandler org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager].level = INFO org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/host-manager].handlers = 4host-manager.org.apache.juli.AsyncFileHandler # For example, set the org.apache.catalina.util.LifecycleBase logger to log # each component that extends LifecycleBase changing state: #org.apache.catalina.util.LifecycleBase.level = FINE # To see debug messages in TldLocationsCache, uncomment the following line: #org.apache.jasper.compiler.TldLocationsCache.level = FINE # To see debug messages for HTTP/2 handling, uncomment the following line: #org.apache.coyote.http2.level = FINE # To see debug messages for WebSocket handling, uncomment the following line: #org.apache.tomcat.websocket.level = FINE
2.4.2、黑窗一闪而过
没有正确配置JAVA_HOME环境变量
2.5、启动报错
2.5.1、暴力
找到占用的端口号,并且找到对应的进程,杀死该进程
netstat -ano
2.5.2、温柔:修改自身的端口号
进入conf/server.xml
<Connector port="8888" protocol="HTTP/1.1" onnectionTimeout="20000" redirectPort="8445" />
一般会将tomcat的默认端口号修改为80,80端口号是http协议的默认端口号,在访问时,就不用输入端口号
这篇关于JAVA WEB1——初始JAVAWEB的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-12-24怎么修改Kafka的JVM参数?-icode9专业技术文章分享
- 2024-12-23线下车企门店如何实现线上线下融合?
- 2024-12-23鸿蒙Next ArkTS编程规范总结
- 2024-12-23物流团队冬至高效运转,哪款办公软件可助力风险评估?
- 2024-12-23优化库存,提升效率:医药企业如何借助看板软件实现仓库智能化
- 2024-12-23项目管理零负担!轻量化看板工具如何助力团队协作
- 2024-12-23电商活动复盘,为何是团队成长的核心环节?
- 2024-12-23鸿蒙Next ArkTS高性能编程实战
- 2024-12-23数据驱动:电商复盘从基础到进阶!
- 2024-12-23从数据到客户:跨境电商如何通过销售跟踪工具提升营销精准度?