2017-10-19 87 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> 

它现在工作。

相关问题