在Dynamic Project中使用Eclipse中的Spring时,请求的资源不可用

时间:2015-03-16 08:59:37

标签: eclipse spring

我在Eclipse中创建了一个动态项目,但是当我打开时,它抛出了ClassNotFound异常,即#34; Web应用程序[/ HelloWorld]中的Servlet [HelloWorld]抛出了load()异常java.lang.ClassNotFoundException:org .springframework.web.servlet.DispatcherServlet"从服务器。这是一个简单的项目 - HelloWorld。 这是我的web.xml:

    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xmlns="http://xmlns.jcp.org/xml/ns/javaee"  
             xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee 
             http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"      
             id="WebApp_ID" version="3.1">
    <display-name>HelloWorld</display-name>
    <welcome-file-list>
       <welcome-file>redirect.jsp</welcome-file>
    </welcome-file-list>
    <servlet>
       <servlet-name>HelloWorld</servlet-name>
       <servlet-class>
           org.springframework.web.servlet.DispatcherServlet
       </servlet-class>      
       <load-on-startup>1</load-on-startup>
    </servlet>

   <servlet-mapping>
    <servlet-name>HelloWorld</servlet-name>
    <url-pattern>*.html</url-pattern>
   </servlet-mapping>
 </web-app>

这是HelloWorld-servlet.xml:

   <beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemalocation="http://www.springframework.org/schema/beans
                    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
                    http://www.springframework.org/schema/context
                    http://www.springframework.org/schema/context/spring-context-3.0.xsd">

<context:component-scan base-package="controller">
    <bean id="viewResolver"
        class="org.springframework.web.servlet.view.UrlBasedViewResolver">
        <property name="caseSensitive" value="true"></property>
        <property name="viewClass"
            value="org.springframework.web.servlet.view.JstlView">
            <property name="prefix" value="/WEB-INF/jsp/">
                <property name="suffix" value=".jsp">
                </property>
            </property>
        </property>
    </bean>
</context:component-scan>
</beans>

这是redirect.jsp:

   <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
   <% response.sendRedirect("hello.html");%>

这是helloworldcontroller.java

    import org.springframework.stereotype.Controller;
    import org.springframework.ui.ModelMap;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.servlet.ModelAndView;

    @Controller
    public class helloworldcontroller {

   @RequestMapping(value="/hello")
   public ModelAndView index(ModelMap m)
   {
    String mss = "Hello World";
    return new ModelAndView("hello", "ms", mss);
   }
   }

当我导入其他人的某些项目时,它运行时没有异常。但我按照一步一步创建新项目,它总是抛出异常。这让我发疯了。我需要帮忙。谢谢!

0 个答案:

没有答案