学习文档:https://blog.csdn.net/qq_36188127/article/details/109370717
学习视频:https://www.bilibili.com/video/BV12J411M7Sj
网站访问流程:
1.输入一个域名,回车,
2.检查本机的C:\Windows\System32\driveretc\hosts配置文件下有没有这个域名映射
a.有:直接返回对应的ip地址,在这个地址中有需要访问的web程序,可以直接访问
b.没有:去DNS服务器找,找到的话返回,找不到就会返回404
HTTP
http默认端口号80
https默认端口号443
servlet(接口)
maven父工程添加servlet
<dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>4.0.1</version> </dependency>
maven子工程添加核心架包(工程创建后一般会自动生成)
<?xml version="1.0" encoding="UTF-8"?> <!--Maven版本和头文件--> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <!--这里就是我们刚才配置的GAV--> <groupId>com.kuang</groupId> <artifactId>javaweb-01-maven</artifactId> <version>1.0-SNAPSHOT</version> <!--Package:项目的打包方式 jar:java应用 war:JavaWeb应用 --> <packaging>war</packaging> <!--配置--> <properties> <!--项目的默认构建编码--> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <!--编码版本--> <maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.compiler.target> </properties> <!--项目依赖--> <dependencies> <!--具体依赖的jar包配置文件--> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.11</version> </dependency> </dependencies> <!--项目构建用的东西--> <build> <finalName>javaweb-01-maven</finalName> <pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) --> <plugins> <plugin> <artifactId>maven-clean-plugin</artifactId> <version>3.1.0</version> </plugin> <!-- see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_war_packaging --> <plugin> <artifactId>maven-resources-plugin</artifactId> <version>3.0.2</version> </plugin> <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>3.8.0</version> </plugin> <plugin> <artifactId>maven-surefire-plugin</artifactId> <version>2.22.1</version> </plugin> <plugin> <artifactId>maven-war-plugin</artifactId> <version>3.2.2</version> </plugin> <plugin> <artifactId>maven-install-plugin</artifactId> <version>2.5.2</version> </plugin> <plugin> <artifactId>maven-deploy-plugin</artifactId> <version>2.8.2</version> </plugin> </plugins> </pluginManagement> </build> </project>
将web.xml修改为最新的
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd" version="4.0" metadata-complete="true"> </web-app>
Maven 由于他的约定大于配置,我们之后可以能遇到我们写的配置文件,无法被导出或者生效的问题,解决方案:
在子工程pom.xml末尾中加入
<!--在build中配置resources,来防止我们资源导出失败的问题--> <build> <resources> <resource> <directory>src/main/resources</directory> <includes> <include>**/*.properties</include> <include>**/*.xml</include> </includes> <filtering>true</filtering> </resource> <resource> <directory>src/main/java</directory> <includes> <include>**/*.properties</include> <include>**/*.xml</include> </includes> <filtering>true</filtering> </resource> </resources> </build>
标签:xml,javaweb,plugin,maven,servlet,端口号 From: https://www.cnblogs.com/xinyu-yudian/p/16794115.html