我用springMVC写了一个web项目,tomcat启动和访问首页都正常,跳转页面出现错误

tomcat启动正常了,访问首页面也成功,可是我从首页面跳转到其他页面怎么会报”404“啊?刚开始学习这个,不太懂,请高人解答?
网页错误信息如下:
HTTP Status 404 -
type Status report
message
description The requested resource is not available.
Apache Tomcat/8.0.9
页面配置如下:
首页:
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">


首页















用户名:

密 码:







登录失败页面(成功页面和这个只有汉字有点差异):
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">


登录失败


登录失败



${message }

controller类文件内容:
public class Logincontroller implements Controller{
private Loginservice ls;
public Loginservice getLs() {
return ls;
}
public void setLs(Loginservice ls) {
this.ls = ls;
}
@Override
public ModelAndView handleRequest(HttpServletRequest arg0,
HttpServletResponse arg1) throws Exception {
// TODO Auto-generated method stub
String username=arg0.getParameter("username");
String password=arg0.getParameter("password");
boolean flag=ls.login(username, password);
ModelAndView mv=new ModelAndView();
if(flag){
//往ModelAndView添加共享变量
mv.addObject("message", "恭喜,你赢啦!");
//设置响应的视图名字
mv.setViewName("success");
}else {
mv.addObject("messege", "抱歉,认证失败");
mv.setViewName("fail");
}
return mv;
}
}
public class Accountcontroller implements Controller{
@Override
public ModelAndView handleRequest(HttpServletRequest arg0,
HttpServletResponse arg1) throws Exception {
ModelAndView mav=new ModelAndView();
mav.setViewName("success");
return mav;
}
}
service类文件内容:
public class Loginservice {
public boolean login(String username,String password){
boolean flase=false;
if(username.equals("admin")&&password.equals("admin")){
flase=true;
}
return flase;
}
}
web.xml文件内容:
<?xml version="1.0" encoding="UTF-8"?>

spring_mvc

springmvc
org.springframework.web.servlet.DispatcherServlet
<!-- 加载springmvc的配置文件 -->

contextConfigLocation
classpath:springmvc.xml

1


springmvc
*.htm


index.html
index.htm
index.jsp
default.html
default.htm
default.jsp


spring的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"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd">












此问题稀里糊涂的没有了,应该是tomcat的里边的缓存问题吧。

ghhgfdsdslkkkjeerjje njngfg

ghhgfdsdslkkkjeerjje njngfg

眼睛都看花了,也没有找到@requestMapping(value="访问的路径")这个注解。我记忆中跳转页面都是在controller层添加该注解后才有效

@RequestMapping("privilegeGroup.do")
public ModelAndView privilegeGroup(HttpServletRequest request,
HttpServletResponse response) throws IOException {
ModelAndView mav = new ModelAndView();

    mav.setViewName("forward:/hello.jsp");
    return mav;
}

你直接看报错时,页面上的链接层次结构缺哪层或者多了哪层就可以了

可能控制器路径,没有注册到web.xml中springmvc的Servlet的转发器上面。

404没有找到文件或目录。
return "modules/sys/sysLogin";