XmlBeanDefinitionStoreException 元素 'mvc:resources' 必須不含字元或元素資訊項 [子級], 因為該型別的內容型別為空。
在SSM專案中報 org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 20 in XML document from class path resource [springmvcsevlet.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 20; columnNumber: 25; cvc-complex-type.2.1: 元素 'mvc:resources' 必須不含字元或元素資訊項 [子級], 因為該型別的內容型別為空。
從上面的報錯資訊可以看出是springmvc配置檔案中 mvc:resources(靜態檔案有錯);
下面是我寫的程式碼
<!-- 靜態資源對映 -->
<mvc:resources location="/static/" mapping="/static/**">
</mvc:resources>
<mvc:resources location="/lib/" mapping="/lib/**">
</mvc:resources>
<mvc:resources location="/temp/" mapping="/temp/**">
</mvc:resources>
將程式碼改為
<!-- 靜態資源對映 -->
<mvc:resources location="/static/" mapping="/static/**"/>
<mvc:resources location="/lib/" mapping="/lib/**"/>
<mvc:resources location="/temp/" mapping="/temp/**"/>
就OK了!