您的位置:首页 > 编程语言 > Java开发

Status 500 - Servlet.init() for servlet springMVC threw exception的错误原因

2017-08-17 22:22 573 查看
在学spring mvc时加入

<mvc:annotation-driven/>

<!-- 使用默认的Servlet来响应静态文件 -->

<mvc:default-servlet-handler/>


后报Status 500 - Servlet.init() for servlet springMVC threw exception错误,而且

<mvc:default-servlet-handler/>


会标红报错,

经过研究后我发现原因是:一开始spring的配置文件是idea帮忙创建,没有配好xsd文件

正确配好后为:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd">

</beans>
上面的4.2是我的spring版本,我用的是4.2.0版本。
然后错误就解决了。

一般来说,出现这个错误是因为你的配置文件出现错误,要仔细检查配置文件还有没有其他错误。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
相关文章推荐