spingmvc 配置springmvc-servlet.xml失效500報錯
?Line 12 in XML document from class path resource [springmvc-servlet.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 12; columnNumber: 8; 2 瀛楄妭鐨? UTF-8 搴忓垪鐨勫瓧鑺? 2 鏃犳晥銆?
大概是這個
主要解決方法:
jdk換成1.8? tomcat 中的jre也換成相應(yīng)版本
大多數(shù)情況是由于spingmvc-servlet.xml問題在判斷你本身xml文件沒有結(jié)構(gòu)化錯誤的情況
我的xml現(xiàn)在是這個
<?xml version="1.0" encoding="GB2312"?>
<beans xmlns="http://www.springframework.org/schema/beans"
? ? ? xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
? ? ? xmlns:context="http://www.springframework.org/schema/context"
? ? ? xmlns:mvc="http://www.springframework.org/schema/mvc"
? ? ? xsi:schemaLocation="http://www.springframework.org/schema/beans
? ? ? http://www.springframework.org/schema/beans/spring-beans.xsd
? ? ? http://www.springframework.org/schema/context
? ? ? http://www.springframework.org/schema/context/spring-context.xsd
? ? ? http://www.springframework.org/schema/mvc
? ? ? http://www.springframework.org/schema/mvc/spring-mvc.xsd">
<!-- ? 自動掃描包,讓包指定下的注解生效,由ioc容器統(tǒng)一管理-->
? ?<context:component-scan base-package="com.monan.controller"/>
<!-- ? ?讓spring mvc 不處理靜態(tài)資源-->
? ?<mvc:default-servlet-handler/>
<!--
支持mvc注解驅(qū)動
在spring中一般采用@requestmapping ?注解來完成映射關(guān)系
要想使@requestmapping 注解生效
必須向上下文中注冊defaultannotationhandlermapping
和一個annotationmethodhandleradapter實(shí)例
這兩個實(shí)例分別在類級別和方法級別處理
而annotation-driven 配置幫助我們自動完成上述兩個實(shí)例的注入
-->
? ?<mvc:annotation-driven/>
<!-- ? ?視圖解析器-->
? ?<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"
? ? ? ? ?id="internalResourceViewResolver">
<!-- ? ? ? ?前綴-->
? ? ? ?<property name="prefix" value="/WEB-INF/jsp/"/>
<!-- ? ? ? ?后綴-->
? ? ? ?<property name="suffix" value=".jsp"/>
? ?</bean>
</beans>
可以看到我的encoding發(fā)生了改變

因?yàn)槠鸪醯奈揖褪莡tf-8,然后跑不通,idea 里面tomcat啟動直接報錯
當(dāng)換成了之后就不報錯了,
然后頁面也不會出現(xiàn)500服務(wù)器內(nèi)部出現(xiàn)錯誤的問題