新手springMVC遇到问题,求大神指点intellij-idea平台

rt,刚学springmvc想试一下,然后。。。


我的配置文件:


mvc-dispatcher-servlet.xml


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

       xmlns:mvc="http://www.springframework.org/schema/mvc"

       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

            http://www.springframework.org/schema/mvc

            http://www.springframework.org/schema/mvc/spring-mvc.xsd">


    <context:annotation-config></context:annotation-config>


    <!--指明 controller 所在包,并扫描其中的注解-->

    <context:component-scan base-package="com.lzq.zsk">

        <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"></context:include-filter>

    </context:component-scan>



    <!-- 静态资源(js、image等)的访问 -->

    <mvc:default-servlet-handler/>

    <!-- 开启注解 -->

    <mvc:annotation-driven></mvc:annotation-driven>

    <!--ViewResolver 视图解析器-->

    <!--用于支持Servlet、JSP视图解析-->

    <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">

        <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"></property>

        <property name="prefix" value="/WEB-INF/pages/"></property>

        <property name="suffix" value=".jsp"></property>

    </bean>


</beans>


 MainController.java

 

package com.lzq.zsk.controller;


import org.springframework.stereotype.Controller;

import org.springframework.web.bind.annotation.RequestMapping;


@Controller

@RequestMapping("/hello")

public class MainController {


    @RequestMapping("/mvc")

    public String helloMVC(){

        System.out.println("helo");


        return "home";

    }

}

https://img3.mukewang.com/5cb8398800013c0608000425.jpg

https://img.mukewang.com/5cb8398800018fc308000320.jpg

https://img.mukewang.com/5cb83989000194e008000318.jpg

慕的地8271018
浏览 754回答 7
7回答

互换的青春

试试spring boot吧

芜湖不芜

应该是配置的问题,你的web.xml文件呢?web.xml 有配置 dispatcher-servlet.xml?

萧十郎

没有包含类文件,项目是maven来建的吗,如果是需要配置pom.xml中的plugin或者是在下图这个地方导入需要的依赖包(不建议)

交互式爱情

一个是依赖包的版本问题(高版本名字改了),一个是core的配置不全。

aluckdog

<listener>&nbsp; &nbsp; <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>&nbsp; </listener>web.xml少了上面这句,把Spring容器集成到 Web 应用里面
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java