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

在学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版本。

然后错误就解决了。

一般来说,出现这个错误是因为你的配置文件出现错误,要仔细检查配置文件还有没有其他错误。

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值