2017-10-19 30 views
0

我想創建基本的春季網絡動態項目。
以下是春季圖書館名單。
enter image description here找不到元素'beans'的聲明。在春天

這是我的HelloWeb-servlet.xml代碼。

<?xml version="1.0" encoding="UTF-8"?> 
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_4.0.xsd" 
     bean-discovery-mode="annotated"> 
    <context:component-scan base-package = "com.tutorialspoint" /> 
    <bean class = "org.springframework.web.servlet.view.InternalResourceViewResolver"> 
     <property name = "prefix" value = "/WEB-INF/jsp/" /> 
     <property name = "suffix" value = ".jsp" /> 
    </bean> 
</beans> 


這裏是我的項目結構。 enter image description here

請幫幫我。謝謝。

+0

xmlns看起來很奇怪,通常它有些不同請參閱https://stackoverflow.com/questions/17822466/spring-beans-dtd-and-xmlns例如 – 2017-10-19 05:54:02

+0

@RC我該如何改變 –

回答

0

我已經修改了HelloWeb-servlet.xml。

<beans xmlns = "http://www.springframework.org/schema/beans" 
    xmlns:context = "http://www.springframework.org/schema/context" 
    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-4.0.xsd 
    http://www.springframework.org/schema/context 
    http://www.springframework.org/schema/context/spring-context-4.0.xsd"> 

    <context:component-scan base-package = "com.tutorialspoint" /> 

    <bean class = "org.springframework.web.servlet.view.InternalResourceViewResolver"> 
     <property name = "prefix" value = "/WEB-INF/jsp/" /> 
     <property name = "suffix" value = ".jsp" /> 
    </bean> 

</beans> 

它現在工作。

相關問題