springmvc+mybatis+maven项目集成的时候遇到一个问题,项目搭起来以后,http请求怎么都进不到controller中,页面直接返回404错误,控制台没有报任何错误,请大神帮我看看
来源:互联网 发布:全景视频拼接软件 编辑:程序博客网 时间:2024/05/13 04:17
这是springmvc.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:p="http://www.springframework.org/schema/p"
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/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<!-- 配置扫描的包 -->
<context:component-scan base-package="com.taotao.controller" />
<!-- 注解驱动 -->
<mvc:annotation-driven />
<!-- 配置视图解析器 -->
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
</bean>
<!-- 配置资源映射 -->
<mvc:resources location="/WEB-INF/css/" mapping="/css/**"/>
<mvc:resources location="/WEB-INF/js/" mapping="/js/**"/>
</beans>
____________________________________________________________________________________________________________________________________
这是web.xml的配置
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="taotao" version="2.5">
<display-name>taotao-manager</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<!-- 加载spring容器 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:spring/applicationContext-*.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- 解决post乱码 -->
<filter>
<filter-name>CharacterEncodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>utf-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>CharacterEncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- springmvc的前端控制器 -->
<servlet>
<servlet-name>taotao-manager</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<!-- contextConfigLocation不是必须的, 如果不配置contextConfigLocation, springmvc的配置文件默认在:WEB-INF/servlet的name+"-servlet.xml" -->
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:spring/springmvc.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>taotao-manager</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
____________________________________________________________________________________________________________________________________
这是controller层的代码
package com.taotao.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.taotao.pojo.TbItem;
import com.taotao.service.ItemService;
@Controller
public class ItemControlle {
@Autowired
private ItemService itemService;
@RequestMapping("/item/{itemId}")
@ResponseBody
public TbItem getItemById(@PathVariable Long itemId){
TbItem item = itemService.getItemById(itemId);
return item;
}
}
- springmvc+mybatis+maven项目集成的时候遇到一个问题,项目搭起来以后,http请求怎么都进不到controller中,页面直接返回404错误,控制台没有报任何错误,请大神帮我看看
- springmvc+mybatis+maven项目集成的时候遇到一个问题,项目搭起来以后,http请求怎么都进不到controller中,页面直接返回404错误,控制台没有报任何错误,请大神帮我看看
- springMVC的配置,请大神们看看,有没有哪里有问题,我用Model做返回类型的时候总是映射到URL
- 最近搭建HBase集群时遇到了一个问题,快把我逼疯啦,请各位大神帮我看看该怎么改啊!!!!!
- springmvc项目中调用controller方法报406错误
- springmvc项目中调用controller方法报406错误
- 请大神帮我解释一下一个oc的问题
- SpringMVC中遇到页面跳转出现404错误的问题
- 请大神帮我看看这是什么问题
- 请大神帮我看看这是什么问题
- 请大神帮我看看这是什么问题
- Maven搭建SpringMVC+Mybatis项目时遇到的问题记录
- maven项目遇到的错误
- 大神的错误解释,帮了我一个大忙。
- 请各位大神帮我看看,这是什么原因造成的。。。。。。
- 搭建springMVC+Mybatis的Maven项目过程中遇到的问题汇总。
- 使用eclipse的时候maven项目的项目没有问题,但是项目报×
- 解决eclipse中maven项目build的时候,console显示teminated,没有任何打印信息
- 阿里巴巴与星巴克合作 AR场景识别首次大规模商用
- html--标签
- c++ primer 13.3节练习(定义自己版本的swap函数并排序)
- Centos不能解析域名
- 共同学习Java源代码-数据结构-HashMap(二十)
- springmvc+mybatis+maven项目集成的时候遇到一个问题,项目搭起来以后,http请求怎么都进不到controller中,页面直接返回404错误,控制台没有报任何错误,请大神帮我看看
- PHP与h5 ajax 跨域上传图片解决方案
- [洪流学堂]Hololens开发高级篇1:凝视(Gaze)
- (记录)万象优图图片分析
- Today is a perfect day to start living your dream.
- python2和python3中的range区别
- 关于中文情感分类的知识
- js基本概念(中)之操作符
- java中获取ServletContext的常见方法