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
1.This points to 1. Who calls whom? example: func...
Today I learned a new CSS special effect, the wav...
This article example shares the specific code of ...
Table of contents background Problem Description ...
Table of contents Requirement description: Requir...
Table of contents 1. Overview 1.1 What is strict ...
1. Download the installation package Download add...
This article example shares the specific code of ...
Environment: VMware VCSA 6.7 (VMware-VCSA-all-6.7...
Nginx is configured with the same domain name, wh...
This article mainly introduces how to implement l...
In Beginners' Understanding MySQL Deadlock Pr...
Table of contents UNION Table initialization Exec...
Several typical values of innodb_flush_method f...
Vim is a text editor that we use very often in Li...