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 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘