spring和springmvc常见问题

1、启动错误java.lang.IllegalArgumentException
问题:javax.servlet.ServletException: Servlet.init() for servlet springMVC threw exception
原因:JDK版本与Spring MVC 版本不对应造成的。
解决:Spring 3.x对应1.7.x或以下版本JDK;Spring 4.x对应JDK 1.8.x

2、程序可以正常使用,但xml开头出现红叉
Referenced file contains errors (http://www.springframework.org/schema/context/spring-context-3.2.xsd). For more information, right click on the message in the Problems View and select “Show Details…”
在这里插入图片描述
解决:刚开始我用的校园网,换个网,这个问题就不会出现了。换网之后,鼠标右键validate验证springmvc.xml
校园网无法读取xsd文件,Failed to read schema document ‘http://www.springframework.org/schema/context/spring-context.xsd’,

3、程序可以正常使用,但是配置扫描显示出错
Multiple annotations found at this line:
- cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element ‘context:component-scan’.
- schema_reference.4: Failed to read schema document ‘http://www.springframework.org/schema/context/spring-context.xsd’,
because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not xsd:schema.
在这里插入图片描述
解决:刚开始我用的校园网,换个网,这个问题就不会出现了。问题2和3与xsi:schemaLocation=" "的引号中最后一位有无空格,没有任何关系。此外即使我添加了spring-context.xsd也米有任何用处。

4、spring官网下载文件的方法
官网下载jar、源码、xsd等,可参考文章

5、JSP页面
Multiple annotations found at this line:
- The superclass “javax.servlet.http.HttpServlet” was not found on the Java Build Path
- - Line breakpoint:add.jsp [line: 1]
解决:右键项目——build path——configure build path——Add Library –> server Runtime -> Click Next,选择tomcat即可

6、java.lang.NoClassDefFoundError: org/springframework/asm/ClassVisitor
原因:缺少jar包
org.springframework.asm-3.0.5.RELEASE.jar
解决:导入asm包即可

猜你喜欢

转载自blog.csdn.net/root_zhb/article/details/109195617