1. Add the following dependencies in pom.xml <dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>3.0.1</version> <scope>provided</scope> // This is the scope</dependency> <dependency> <groupId>javax.servlet.jsp</groupId> <artifactId>jsp-api</artifactId> <version>2.2</version> <scope>provided</scope> // This is the scope</dependency> Note: It needs to be placed in I use mvn tomcat:run, which will lead to a problem: although I configure tomcat7, tomcat6 is used by default, and tomcat6 does not support jdk1.8. Here you need to add the tomcat7-maven-plugin plug-in. Note: If your version is tomcat7-maven-plugin 2.0, since it does not support jdk 1.8, just replace it with tomcat7-maven-plugin 2.2. Add the following code in pom.xml: <plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> <version>2.2</version> </plugin> That's it. "IDEA maven cannot import static files such as css, js, img, etc." <servlet-mapping> <servlet-name>default</servlet-name> <url-pattern>*.js</url-pattern> <url-pattern>*.css</url-pattern> <url-pattern>*.map</url-pattern> <url-pattern>*.jpg</url-pattern> <url-pattern>*.png</url-pattern> <url-pattern>*.eot</url-pattern> <url-pattern>*.svg</url-pattern> <url-pattern>*.ttf</url-pattern> <url-pattern>*.woff</url-pattern> <url-pattern>*.otf</url-pattern> <url-pattern>*.woff2</url-pattern> <url-pattern>*.gif</url-pattern> </servlet-mapping> Add to the jsp page: <% String path = request.getContextPath(); String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/"; %> Then you can directly reference bathPath, such as: <link rel="stylesheet" href="<%=basePath%>/css/bootstrap.min.css" rel="external nofollow" type="text/css"> Tomcat created by Maven, running in debug mode 1. First enter the edit structure. 2. Select the green "+" sign and scroll down to find the "Maven" option and click it. 3. Select the project to be debugged. 4. Just run the debug program. 5. Copy this path + file directory and you can access it Modify the front-end code of the Maven project, click somewhere else, and refresh the webpage without restarting Maven. Note: This deployment is only useful for jsp page modification, not for Servlet, and also cannot recognize html This is the end of this article about the detailed tutorial on how to use debug mode to run Tomcat in IDEA Maven project. For more information about how to use debug mode to run Tomcat in IDEA Maven project, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Native js to achieve simple carousel effect
>>: MySQL 8.0.20 installation tutorial and detailed tutorial on installation issues
HTML <div class="spinner"></di...
This article summarizes the principles and usage ...
Everything is a file! UNIX has already said it. E...
Mysql auto-increment primary key id does not incr...
This is an official screenshot. After MySQL 5.7 i...
As the Internet era becomes more mature, the deve...
getElementById cannot get the object There is a s...
Preface The MySQL permission table is loaded into...
How to check where the metadata lock is blocked i...
I remember a question the interviewer asked durin...
Preface I am used to writing less/sass, but now I...
Basic network configuration Although Docker can &...
The following is an introduction to using SQL que...
Table of contents 1. Basic configuration of Nginx...
This article records the installation and configu...