qq_24264771 2015-11-13 01:50 采纳率: 63.6%
浏览 3794
已采纳

我用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 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊
  • ¥15 安装svn网络有问题怎么办