qq_24264771 2015-11-13 01:50 采纳率: 100%
浏览 3796
已采纳

我用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">












  • 写回答

8条回答 默认 最新

  • qq_24264771 2015-12-14 09:00
    关注

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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(7条)

报告相同问题?

悬赏问题

  • ¥15 wpf通过绑定控件自身的值,来实现背景颜色的切换
  • ¥15 CDH6.3 运行hive -e hive -e "show databases;"报错:hive-env.sh:行24: hbase-common.jar: 权限不够
  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线