qq_34867178 2017-01-17 08:28 采纳率: 0%
浏览 933

spring mvc一个简单的入门小例子总报404错误,新手求大神指导

web.xml代码如下:

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

spring-mvc-study2

<!--configure the setting of springmvcDispatcherServlet and configure the mapping-->

springmvc
org.springframework.web.servlet.DispatcherServlet

contextConfigLocation
classpath:springmvc-servlet.xml

1


springmvc
/


index.jsp

springmvc-servlet.xml代码如下:

<?xml version="1.0" encoding="UTF-8"?>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:task="http://www.springframework.org/schema/task"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.3.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-4.3.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-4.3.xsd
http://www.springframework.org/schema/task
http://www.springframework.org/schema/task/spring-task-4.3.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd">

<!-- 启用Spring基于annotation的DI, 使用户可以在Spring MVC中使用Spring的强大功能。 激活 @Required 

@Autowired,JSR 250's @PostConstruct, @PreDestroy and @Resource 等标注 -->

<!-- scan the package and the sub package -->
<context:component-scan base-package="test.SpringMVC">
<context:include-filter type="annotation" expression="org.springframework.stereotype.Controller" />

/context:component-scan

<!-- don't handle the static resource -->
<mvc:default-servlet-handler/>


<!-- if you use annotation you must configure following setting -->
<mvc:annotation-driven />

<!-- configure the InternalResourceViewResolver -->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <!-- 前缀 -->
    <property name="prefix" value="/WEB-INF/jsp/" />
    <!-- 后缀 -->
    <property name="suffix" value=".jsp" />
</bean>

mvcController.java代码如下:

package test.SpringMVC;

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

@Controller
@RequestMapping("/mvc")
public class mvcController {

@RequestMapping("/hello")
public String hello(){ 
System.out.println("hello");
    return "hello";
}

}

项目结构如下:
图片说明

错误如下:
图片说明

求大神帮忙解决,已经烦恼了两天了

  • 写回答

6条回答

  • qq_34867178 2017-01-17 08:32
    关注

    这是我的jar包图片说明

    评论

报告相同问题?

悬赏问题

  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作