Don’t panic in case of data tilt, teach you to easily obtain the slope of table tilt>>>
Analysis of the problems:
Maven is used to manage jar packages. Therefore, when spring MVC framework is used, jar packages such as servlet-api.jar and jsp-api.jar will be manually configured into the project. Otherwise, some JSPS will heartlessly report errors (no corresponding jar package can be found). However, when servlet-api.jar is configured, it may conflict with jar packages in tomcat container, resulting in the above problems, The JSP cannot be found. The problem will only appear in tomcat8 or above, and there is no problem in tomcat7 or below
So if you use tomcat8 and later children’s shoes, you may use the following solutions
Solution:
Solution 1: after publishing the project, remove the servlet-api-xxx.jar from the webapps directory, and restart Tomcat. Remember to restart Tomcat instead of publishing the project
Scheme 2: add server library to the project directly
Right click on the project — > build Path –> Add Library –> Server Library –> Apache Tomcat v8.0 (provided Tomcat 8 and later are integrated into eclipse, or MyEclipse, or other ides used)
the above two solutions are always a little palliative for using Maven projects. The purpose of using Maven is to completely control the dependency of jar packages. If jars need to be added or deleted manually at that time, it will be very troublesome in team collaboration, so we need to provide another solution here
Scheme 3: add scope and limit it to provided
Add provided restriction:
The scope provided by the container or JDK indicates that the dependent package has been provided by the target container (such as Tomcat) and JDK. It is only loaded and used in the compiled classpath and will not be included in the target package when it is packaged. The most common jar packages are servlet API and JSP API related to J2EE specification, which are generally provided by servlet container and need not be packaged into war package. If they are not configured as provided, these packages will be packaged into project war package, and there will be conflicts in Tomcat6 and above versions, and the program will not run normally
<dependency>
<groupId>tomcat</groupId>
<artifactId>servlet-api</artifactId>
<version>5.5.23</version>
<scope>provided</scope>
</dependency>
Similar Posts:
- Tomcat10 Error: java.lang.NoClassDefFoundError: javax/servlet/ServletContextListener
- Error during artifact deployment. See server log f
- Maven does not have a servlet (an error is reported after the servlet is created)
- Springboot always reports an error when importing JSP dependencies
- Tomcat Startup Error: Server Tomcat v8.5 Server at localhost failed to start.
- The difference between web app libraries and referenced libraries in eclipse project
- The following table: unable to import javax. Servlet. HttpServletRequest
- Using idea and maven, there is an error: (4, 21) Java: there is no problem with the package javax.servlet
- Unregistering JMX-exposed beans on shutdown Solution
- [Solved] IDEA: JSP Could Not Use session Build-in Object