spring mvc-用idea15开发 springmvc项目时报404错误,求大神告知原因

问题描述

用idea15开发 springmvc项目时报404错误,求大神告知原因

web.xml配置如下:

rest
org.springframework.web.servlet.DispatcherServlet

contextConfigLocation
/WEB-INF/rest-servlet.xml

1

rest
/restful/*

    rest-servlet.xml配置如下:
    <beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
    http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context-3.0.xsd
    http://www.springframework.org/schema/mvc
    http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">

<description>Spring MVC for Restful</description>
<!--检测注解 -->
<context:component-scan base-package="com.onlyyou.java.controller" />
<context:annotation-config />
<mvc:annotation-driven />
<mvc:default-servlet-handler/>
</beans>

Controller代码如下:
@Controller

@RequestMapping("/hello")
public class HelloController {
@RequestMapping(value="/user", method= RequestMethod.GET)
@ResponseBody
public UserBean testParam(@RequestParam("username") String name) {
UserBean userBean = new UserBean();
userBean.setAvatar("123");
userBean.setBirthday("323");
userBean.setCensusRegister("dfda");
return userBean;

}

}
最后再浏览器访问http://localhost:6080/onlyyou/restful/hello/user?username=tom报404的错误

解决方案

重新粘贴一下代码,web.xml如下:
<?xml version="1.0" encoding="UTF-8"?>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">

contextConfigLocation
/WEB-INF/applicationContext.xml

org.springframework.web.context.ContextLoaderListener

<servlet>
    <servlet-name>rest</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/rest-servlet.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>rest</servlet-name>
    <url-pattern>/restful/*</url-pattern>
</servlet-mapping>

解决方案二:

6080端口,,写错了吗?

时间: 2024-07-28 20:11:16

spring mvc-用idea15开发 springmvc项目时报404错误,求大神告知原因的相关文章

用的spring mvc 添加了分页 功能后一直报错 求大神解决

问题描述 用的spring mvc 添加了分页 功能后一直报错 求大神解决 org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerExceptionResolver]Resolving exception from handler [com.app.controller.ManageController@185c0de]: java.lang.NumberFormatException: For input s

spring+springmvc+mybatis 报错。求大神指教。

问题描述 spring+springmvc+mybatis 报错.求大神指教. 严重: StandardWrapper.Throwableorg.springframework.beans.factory.BeanCreationException: Error creating bean with name 'index': Injection of autowired dependencies failed; nested exception is org.springframework.b

ios开发-IOS开发使用自定义字体路径问题求大神

问题描述 IOS开发使用自定义字体路径问题求大神 在项目开发中,我需要实现服务器管理UI风格,返回给我一个TTF格式的自定义字体包,我在加载里面的字体,问题就是服务器返给我的TTF字体包,我保存在沙盒里面读取不到.网上也找了很多资料,都没有答案,请问大神该怎么样解决.或者说我怎么把下载的字体加载到我的工程中 解决方案 http://blog.sina.com.cn/s/blog_9bf8abf301018pbr.html 解决方案二: iOS开发 - 使用自定义字体ios 使用自定义字体IOS使

springMVC配置报错,求大神帮忙

问题描述 springMVC配置报错,求大神帮忙 解决方案 解决方案二: 解决方案三: 解决方案四: 解决方案五: No mapping found for HTTP request with URI [/demo/index.html] in DispatcherServlet with name 'spring' 说的很明白了 解决方案六: 建立也demo文件夹,把index.html挪进去. 解决方案七: RequestMapping("/demo/*")试试

springmvc-公司的项目架构奇特,求大神给个藤小弟好摸瓜

问题描述 公司的项目架构奇特,求大神给个藤小弟好摸瓜 公司项目吧Service,Dao等不同的层写在不同的project里面,然后通过启动项admin启动,同时在admin的spring配置文件里把不同层的配置文件都import进来,在myeclipse里面跑的没问题,但是在eclipse里面跑的时候,tomcat只会编译admin的内容,然后报错说找不到别的xml文件,求大神给解答下,则么破,还有这种架构的激励神马的,小弟感激不尽 解决方案 你的maven项目吧?或者在库中导入其他项目,起到关

框架-初练SpringMVC遇到的问题,求大神解答

问题描述 初练SpringMVC遇到的问题,求大神解答 TomCat启动无异常,肯定是上面哪里写错了或写少了? 解决方案 直接用view.setViewName("hello");或者view.setViewName("webInfo/hello").试试,问题是找不到你的页面,也就是你的ModelAndView中设置的页面路径不对. 解决方案二: 你的项目名都不加吗????????那当然找不到啦 localhost/hello 怎么可能请求的到呢 解决方案三: 路

急 急 急C# 开发微信公众号 上传图片代码 求大神指导 真给C币 不骗人

问题描述 急 急 急C# 开发微信公众号 上传图片代码 求大神指导 真给C币 不骗人 我用C#开发微信公众号遇到了这样一个问题,在这个页面我需要上传一个图片到微信服务器里,并且返回图片的路径. 只要不能传上去并且返回路径 就可以了 不要说那些接口 我开发微信是半路出家 不怎么懂,还恳求各路大神帮忙!!! 这个图片是我页面的一个截图 解决方案 不能上传,有什么错误提示吗? 解决方案二: 直接给你吧 我自己脑补出来了 解决方案三: 直接给你吧 我自己脑补出来了

spring配置错误 求大神

问题描述 spring配置错误 求大神 严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFac

log explorer-为恢复sql server2005数据库数据,安装Log Explorer时报错,求大神帮忙看看。

问题描述 为恢复sql server2005数据库数据,安装Log Explorer时报错,求大神帮忙看看. 解决方案 1.Lumigent Log Explorer for SQL Server v4.0.2 特别版下载地址http://down.chinaz.com/soft/7887.htm Log Explorer for SQL Server 4.2 注册码 wv5rc-uxvpz-e33-nr4694qs2 2.Log Explorer for SQL Server v4.0.2 安