Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring MVC 4项目(找不到InternalResourceViewResolver类)_Spring_View_Resources_Internal_Resolver - Fatal编程技术网

Spring MVC 4项目(找不到InternalResourceViewResolver类)

Spring MVC 4项目(找不到InternalResourceViewResolver类),spring,view,resources,internal,resolver,Spring,View,Resources,Internal,Resolver,在做出任何回应之前,请自己测试一下。因为我已经用不同的spring框架版本尝试了所有的IDE。我尝试了4.0.4到最新的4.2。但从来没有得到正确的答案。请帮助我,指引我。提前谢谢 这是我的控制器类HelloWorld package controllers; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; impo

在做出任何回应之前,请自己测试一下。因为我已经用不同的spring框架版本尝试了所有的IDE。我尝试了4.0.4到最新的4.2。但从来没有得到正确的答案。请帮助我,指引我。提前谢谢

这是我的控制器类HelloWorld

package controllers;

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

@Controller

public class HelloWorld {
    @RequestMapping("/hi")
    public ModelAndView hello(){
        ModelAndView modelAndView= new ModelAndView("index");
        modelAndView.addObject("msg", "Hi there......");
        return modelAndView;
    }
}
这是我的spring配置文件

<?xml version="1.0" encoding="UTF-8"?>

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

    <context:component-scan base-package="controllers"/>

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

</beans>

/WEB-INF/
.jsp
这是我的web.xml文件

<!DOCTYPE web-app PUBLIC
 "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
 "http://java.sun.com/dtd/web-app_2_3.dtd" >

<web-app>
  <display-name>Archetype Created Web Application</display-name>
  <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value></param-value>
    </context-param>  
  <servlet>
    <servlet-name>dispatcher</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>/WEB-INF/dispatcher-servlet.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>dispatcher</servlet-name>
    <url-pattern>/</url-pattern>
  </servlet-mapping>
</web-app>

Web应用程序创建的原型
上下文配置位置
调度员
org.springframework.web.servlet.DispatcherServlet
上下文配置位置
/WEB-INF/dispatcher-servlet.xml
1.
调度员
/
这是我的pom文件

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.RESTfullService.learning</groupId>
  <artifactId>SpringMVC4part8</artifactId>
  <packaging>war</packaging>
  <version>0.0.1-SNAPSHOT</version>
  <name>SpringMVC4part8 Maven Webapp</name>
  <url>http://maven.apache.org</url>
  <dependencies>
    <!-- spring-context which provides core functionality -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>4.1.6.RELEASE</version>
        </dependency>

        <!-- The spring-aop module provides an AOP Alliance-compliant aspect-oriented 
            programming implementation allowing you to define -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-aop</artifactId>
            <version>4.1.6.RELEASE</version>
        </dependency>

        <!-- The spring-webmvc module (also known as the Web-Servlet module) contains 
            Spring’s model-view-controller (MVC) and REST Web Services implementation 
            for web applications -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>4.1.6.RELEASE</version>
        </dependency>

        <!-- The spring-web module provides basic web-oriented integration features 
            such as multipart file upload functionality and the initialization of the 
            IoC container using Servlet listeners and a web-oriented application context -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>4.1.6.RELEASE</version>
        </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
  <build>
    <finalName>SpringMVC4part8</finalName>
  </build>
</project>

4.0.0
com.RESTfullService.learning
SpringMVC4part8
战争
0.0.1-快照
SpringMVC4part8 Maven Webapp
http://maven.apache.org
org.springframework
spring上下文
4.1.6.1发布
org.springframework
春季aop
4.1.6.1发布
org.springframework
SpringWebMVC
4.1.6.1发布
org.springframework
弹簧网
4.1.6.1发布
朱尼特
朱尼特
3.8.1
测试
SpringMVC4part8
这是index.jsp文件

<html>
<head>
    <title></title>
</head>
<body>
<h2>${msg}</h2>
</body>
</html>

${msg}

课程包不正确。它应该是
org.springframework.web.servlet.view.InternalResourceViewResolver