Servlet.init()引發異常—xml文件中文注釋問題


正確的設置了第一個SpringMVC相關的配置,初始啟動服務器時,報404,經過排查,是項目生成構建的時候沒有導入好依賴,手動在項目結構里面新建lib目錄添加依賴解決了404的問題,重新部署以后開始報500內部服務器錯誤

經過仔細查找,最終發現問題發生在 springmvc-servelt.xml文件中

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

    <bean class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping"/>
    <bean class="org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter"/>

    <!--視圖解析器:DispatcherServlet給他的ModelAndView-->
    <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver" id="InternalResourceViewResolver">
        <!--前綴-->
        <property name="prefix" value="/WEB-INF/jsp/"/>
        <!--后綴-->
        <property name="suffix" value=".jsp"/>
    </bean>


    <!--Handler-->
    <bean id="/hello" class="com.Cra2iTeT.controller.HelloController"/>

</beans>

中文注釋導致了文件初始化失敗,這個問題在Mybatis學習過程中,xml文件編寫時就遇到過,算是一個坑,把中文注釋給刪除掉就可以解決問題。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM