问题描述
- 新手求助!在MyEclipse导入Struts框架搭建的项目出现404错误!
-
HTTP Status 404 - /16/WebRoot/admin_index.jsp
type Status reportmessage /16/WebRoot/admin_index.jsp
description The requested resource is not available.
Apache Tomcat/7.0.63
struts.xml的配置文件如下:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">/admin_{1}.jsp
/admin_{1}.jsp/car_{1}.jsp
/car_{1}.jsp
car_queryCarList.action/customer_{1}.jsp
customer_queryCustomerList.action
customer_queryCustomerList.action/goods_{1}.jsp
goods_queryGoodsList.action
web.xml的配置文件:
<?xml version="1.0" encoding="UTF-8"?>
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">struts2
org.apache.struts2.dispatcher.FilterDispatcherstruts2
/*index.jsp
一部分AdminAction的代码:
public class AdminAction extends AdminForm {
private static AdminDao adminDao = null;static{ adminDao=new AdminDao(); } // 对登录用户的表单验证是否为空 public void validateIndex() { if (null == admin_user || admin_user.equals("")) { this.addFieldError("admin_user", "| 请您输入用户名"); } if (null == admin_password || admin_password.equals("")) { this.addFieldError("admin_password", "| 请您输入密码"); } } // 对登录用户的表单验证 public String index() { String query_password = adminDao.getAdminPassword(admin_user); if (query_password.equals("")) { this.addActionError("| 该用户名不存在"); return INPUT; } if (!query_password.equals(admin_password)) { this.addActionError("| 您输入的密码有误,请重新输入"); return INPUT; } session.put("admin_user", admin_user); return SUCCESS; } // 对修改管理员密码表单验证是否为空 public void validateUpdatePassword() { if (null == admin_password || admin_password.equals("")) { this.addFieldError("admin_password", "请输入原密码"); } if (null == admin_repassword1 || admin_repassword1.equals("")) { this.addFieldError("admin_repassword1", "请输入新密码"); } if (null == admin_repassword2 || admin_repassword2.equals("")) { this.addFieldError("admin_repassword2", "请输入密码确认"); } if (!admin_repassword1.equals(admin_repassword2)) { this.addActionError("您输入两次密码不相同,请重新输入!!!"); } } public String updatePassword() { String query_password = adminDao.getAdminPassword(admin_user); if (!admin_password.equals(query_password)) { this.addFieldError("admin_password", "您输入的原密码有误,请重新输入"); } String sql = "update tb_admin set admin_password='" + admin_repassword1 + "' where admin_user='" + admin_user + "'"; if (!adminDao.operationAdmin(sql)) { this.addActionError("修改密码失败!!!"); return INPUT; } else { request.setAttribute("editPassword", "您修改密码成功,请您重新登录!!!"); return SUCCESS; } }
}
第一次提问,希望大神们多多指教!小弟也会虚心受教。
解决方案
报404状态码,表示请求的资源不可用或请求的页面不存在。你访问的页面为admin_index.jsp,而那个web.xml文件设置的为index.jsp,所以你要把web.xml文件的配置改成admin_index.jsp。
解决方案二:
MyEclipse导入现成项目出现错误
解决方案三:
找不到admin_index.jsp,查查路径正确吗