如何详细操作IDEA中创建Maven工程并配置Servlet?
- 内容介绍
- 文章标签
- 相关推荐
本文共计741个文字,预计阅读时间需要3分钟。
IDEA创建Maven项目,配置Servlet和Servlet Applet,全面了解Java Servlet,用于开发动态Web资源的技术。
Java Servlet是Java编写的服务器端程序,主要功能是处理服务器请求。它主要用于处理服务器请求,提供动态内容。Tomcat是由Apache组织提供的Servlet容器,用于运行Servlet程序。
IDEA创建Maven工程servlet
Servlet(Servlet Applet),全称Java Servlert,用于开发动态web资源的技术。是用Java编写的服务器端程序,主要功能在于处理服务器请求。
Tomcat:由Apache组织提供的一种Web服务器,提供对jsp和Servlet的支持。它是一种轻量级的javaWeb容器(服务器),也是当前应用最广的JavaWeb服务器(免费)。
jsp:(java server page),java提供的一门开发web网页的技术。
web应用完全是基于java.sun.com/dtd/web-app_2_3.dtd" > <web-app> <servlet> <servlet-name>MyServlet</servlet-name> <servlet-class>com.bigdata.servlet.MyServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>MyServlet</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> </web-app>
四、jsp代码
hello.jsp代码如下:
<%-- Created by IntelliJ IDEA. User: bigdata Date: 2020/10/25 Time: 17:28 To change this template use File | Settings | File Templates. --%> <%@ page contentType="text/html;charset=UTF-8" language="java" %> <html> <head> <title>才开始学java,要坚持到底</title> </head> <body> welcome to learn java,come on ~ </body> </html>
五、pom配置文件
1)获取项目依赖的jar包
Maven中央仓库
可以去Maven中央仓库获取Servlet依赖的jar包的坐标
Servlet完整的pom配置文件如下:
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="maven.apache.org/POM/4.0.0" xmlns:xsi="www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="maven.apache.org/POM/4.0.0 maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.bigdata</groupId> <artifactId>maven_web</artifactId> <version>1.0-SNAPSHOT</version> <packaging>war</packaging> <dependencies> <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>4.0.1</version> <scope>provided</scope> </dependency> <dependency> <groupId>javax.servlet.jsp</groupId> <artifactId>jsp-api</artifactId> <version>2.2</version> <scope>provided</scope> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.12</version> <scope>test</scope> </dependency> </dependencies> <!-- 修改maven工程运行环境 --> <!-- 修改tomcat环境 --> <build> <plugins> <plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> <version>2.2</version> <configuration> <port>8888</port> </configuration> </plugin> <!-- 修改maven-compiler-plugin环境 --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.6.1</version> <configuration> <target>11</target> <source>11</source> <encoding>UTF-8</encoding> </configuration> </plugin> </plugins> </build> </project>
六、运行Servlet项目
查看页面
至此IDEA创建Maven工程Servlet完成
到此这篇关于IDEA创建Maven工程Servlet的详细教程的文章就介绍到这了,更多相关IDEA创建Maven工程内容请搜索易盾网络以前的文章或继续浏览下面的相关文章希望大家以后多多支持易盾网络!
本文共计741个文字,预计阅读时间需要3分钟。
IDEA创建Maven项目,配置Servlet和Servlet Applet,全面了解Java Servlet,用于开发动态Web资源的技术。
Java Servlet是Java编写的服务器端程序,主要功能是处理服务器请求。它主要用于处理服务器请求,提供动态内容。Tomcat是由Apache组织提供的Servlet容器,用于运行Servlet程序。
IDEA创建Maven工程servlet
Servlet(Servlet Applet),全称Java Servlert,用于开发动态web资源的技术。是用Java编写的服务器端程序,主要功能在于处理服务器请求。
Tomcat:由Apache组织提供的一种Web服务器,提供对jsp和Servlet的支持。它是一种轻量级的javaWeb容器(服务器),也是当前应用最广的JavaWeb服务器(免费)。
jsp:(java server page),java提供的一门开发web网页的技术。
web应用完全是基于java.sun.com/dtd/web-app_2_3.dtd" > <web-app> <servlet> <servlet-name>MyServlet</servlet-name> <servlet-class>com.bigdata.servlet.MyServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>MyServlet</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> </web-app>
四、jsp代码
hello.jsp代码如下:
<%-- Created by IntelliJ IDEA. User: bigdata Date: 2020/10/25 Time: 17:28 To change this template use File | Settings | File Templates. --%> <%@ page contentType="text/html;charset=UTF-8" language="java" %> <html> <head> <title>才开始学java,要坚持到底</title> </head> <body> welcome to learn java,come on ~ </body> </html>
五、pom配置文件
1)获取项目依赖的jar包
Maven中央仓库
可以去Maven中央仓库获取Servlet依赖的jar包的坐标
Servlet完整的pom配置文件如下:
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="maven.apache.org/POM/4.0.0" xmlns:xsi="www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="maven.apache.org/POM/4.0.0 maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.bigdata</groupId> <artifactId>maven_web</artifactId> <version>1.0-SNAPSHOT</version> <packaging>war</packaging> <dependencies> <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>4.0.1</version> <scope>provided</scope> </dependency> <dependency> <groupId>javax.servlet.jsp</groupId> <artifactId>jsp-api</artifactId> <version>2.2</version> <scope>provided</scope> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.12</version> <scope>test</scope> </dependency> </dependencies> <!-- 修改maven工程运行环境 --> <!-- 修改tomcat环境 --> <build> <plugins> <plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> <version>2.2</version> <configuration> <port>8888</port> </configuration> </plugin> <!-- 修改maven-compiler-plugin环境 --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.6.1</version> <configuration> <target>11</target> <source>11</source> <encoding>UTF-8</encoding> </configuration> </plugin> </plugins> </build> </project>
六、运行Servlet项目
查看页面
至此IDEA创建Maven工程Servlet完成
到此这篇关于IDEA创建Maven工程Servlet的详细教程的文章就介绍到这了,更多相关IDEA创建Maven工程内容请搜索易盾网络以前的文章或继续浏览下面的相关文章希望大家以后多多支持易盾网络!

