十月 11, 2017 9:11:27 上午 org.springframework.web.servlet.DispatcherServlet noHandl

儿时可乖了 2017-10-11 10:03:29
错误信息:十月 11, 2017 9:11:27 上午 org.springframework.web.servlet.DispatcherServlet noHandlerFound
警告: No mapping found for HTTP request with URI [/YiYuanDecoration/user/getAllUser] in DispatcherServlet with name 'springMVC'

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="WebApp_ID" version="2.5">
<display-name>YiYuanDecoration</display-name>
<welcome-file-list>
<welcome-file>login.jsp</welcome-file>
</welcome-file-list>

<!-- 加载spring -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:config/spring/spring-common.xml</param-value>
</context-param>

<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- 加载springMVC核心控制器 -->
<servlet>
<servlet-name>springMVC</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:config/spring/spring-mvc.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>


<servlet-mapping>
<servlet-name>springMVC</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>




<!-- 处理乱码的过滤器 -->
<filter>
<filter-name>encoding</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>encoding</filter-name>
<url-pattern>/*</url-pattern>

</filter-mapping>



<context-param>
<param-name>ImagePath</param-name>
<param-value>http://47.94.101.83:8080/YiYuanDecoration/upload/</param-value>
</context-param>
<context-param>
<param-name>CodeUrl</param-name>
<param-value>http://47.94.101.83:8080/panoVr/examples/example.html?imgurl=</param-value>
</context-param>


<servlet>
<description>This is the description of my J2EE component</description>
<display-name>This is the display name of my J2EE component</display-name>
<servlet-name>getQrcode</servlet-name>
<servlet-class>com.jgd.vr.getQrcode</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>getQrcode</servlet-name>
<url-pattern>/getQrcode</url-pattern>
</servlet-mapping>


</web-app>


spring_mvc:
<?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-3.2.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd">


<!-- 开启注解 -->
<mvc:annotation-driven />
<!-- 注解扫描包 -->
<context:annotation-config />
<context:component-scan base-package="com" />

<!-- 静态资源(js/image)的访问 -->
<mvc:resources location="/js/" mapping="/js/**"/>
<mvc:resources location="/upload/" mapping="/upload/**"/>

<!-- 定义视图解析器 -->
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/"></property>
<property name="suffix" value=".jsp"></property>
</bean>
</beans>


控制器:
package com.tgb.controller;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

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

import com.tgb.dao.UserManager;
import com.tgb.entity.User;

@Controller
@RequestMapping("/user")
public class UserController {

@Resource
private UserManager userManager;

/**
* 获取全部用户
*/
@RequestMapping("/getAllUser")
public String getAllUser(HttpServletRequest request) {
System.out.println("进入控制器");
System.out.println("进入控制器");
System.out.println("进入控制器");
request.setAttribute("userList", userManager.getAllUser());

return "/index";
}

@RequestMapping("login")
public String login(User user) {
System.out.println(user.getUserId());
System.out.println(user.getPassWord());

String a = userManager.Login(user);
if (a.equals("1")) {
return "success";
} else {

return "error";
}

}

}


jsp页面:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script type="text/javascript" src="../js/jquery-1.7.1.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<h5><a href="user/getAllUser">进入用户管理页</a></h5>


</body>
</html>


问题:从JSP页面跳转到控制器报错,404
错误信息:十月 11, 2017 9:11:27 上午 org.springframework.web.servlet.DispatcherServlet noHandlerFound
警告: No mapping found for HTTP request with URI [/YiYuanDecoration/user/getAllUser] in DispatcherServlet with name 'springMVC'

...全文
161 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
usecf 2017-10-11
  • 打赏
  • 举报
回复
<filter-mapping> <filter-name>encoding</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> 改成 <filter-mapping> <filter-name>encoding</filter-name> <url-pattern>/</url-pattern> </filter-mapping>
儿时可乖了 2017-10-11
  • 打赏
  • 举报
回复
目录结构

61,114

社区成员

发帖
与我相关
我的任务
社区描述
层叠样式表(英文全称:Cascading Style Sheets)是一种用来表现HTML(标准通用标记语言的一个应用)或XML(标准通用标记语言的一个子集)等文件样式的计算机语言。
社区管理员
  • HTML(CSS)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧