HTTP Status 404 – /LoginSystem/user/UserLogin;jsessionid=7511E5BC2AFDD4BA267B0D1740312A57 ——————————————————————————– type Status report message /LoginSystem/user/UserLogin;jsessionid=7511E5BC2AFDD4BA267B0D1740312A57 description The requested resource (/LoginSystem/user/UserLogin;jsessionid=7511E5BC2AFDD4BA267B0D1740312A57) is not available. 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"> <struts> <constant name="struts.enable.DynamicMethodInvocation" value="false" /> <constant name="struts.devMode" value="true" /> <!-- 原来的基础上增加了命名空间 --> <package name="com.web" extends="struts-default"> <interceptors> <interceptor name="Authentication" class="com.web.interceptor.AuthenticationInterceptor" /> <interceptor-stack name="NoticeAuthenticationStack"> <interceptor-ref name="createSession" /> <interceptor-ref name="exception"/> <interceptor-ref name="validation"> </interceptor-ref> <interceptor-ref name="Authentication" /> </interceptor-stack> </interceptors> <!-- 管理员登录 --> <action name="AdminLogin" class="com.action.admin.AdminLoginAction"> <!-- /admin/test.jsp自己建的测试页面,以前是/admin/Userlist.action --> <result name="success" type="redirect">/admin/test.jsp</result> <result name="input">/admin/adminlogin.jsp</result> </action> <action name="AdminLogout" class="com.action.admin.AdminLogoutAction"> <result name="input">/admin/adminlogin.jsp</result> </action> <!-- 由于用户可以随意浏览公告所以list页不需要配拦截器 --> <!-- 可以考虑删掉这部分,用其他JSP替代 --> <!-- <action name="NoticeList" class="com.web.user.NoticeManagerAction" method="list"> <result name="list">/user/noticelist.jsp</result> </action> --> <!-- 用户登录 --> <action name="UserLogin" class="com.action.user.UserLoginAction"> <!-- 把.action后缀换成.jsp --> <!-- 成功页面以前是/user/noticelist.action --> <result name="success" type="redirect">/user/test.jsp</result> <result name="input">/user/userlogin.jsp</result> </action> <action name="UserLogout" class="com.action.user.UserLogoutAction"> <result name="input">/user/userlogin.jsp</result> </action> </package> </struts>[/code action类 [code=java]package com.action.user; import java.util.List; import java.util.Map; /** * 该类功能:userlogin.action请求将访问控制器组件UserLoginAction类。 * 该类的作用就是获取模型组传递过来的数据,并经过查询数据库进行身份验 * 证,操作完成后,将请求发送到配置文件定义好的界面中去 * * * 还有几个包没有import进来,还有几个类没创建,所以有错误! */ import com.dao.UserDao; import com.dao.impl.UserDaoImpl; import com.model.Users; import com.opensymphony.xwork2.ActionSupport; import org.apache.struts2.interceptor.SessionAware; import com.web.interceptor.AuthenticationInterceptor; public class UserLoginAction extends ActionSupport implements SessionAware{ /** * */ private static final long serialVersionUID = 1L; //实例化UserDAO UserDao dao=new UserDaoImpl(); private String username; private String password; private Map session; public String execute() throws Exception{ /* 判断一般用户的用户名和密码: * 输入正确则进入首页,输入错误则返回登陆页面 * */ Users user=dao.isValidUser(username,password); if(user!=null){ session.put(AuthenticationInterceptor.USER_SESSION_KEY, user); return SUCCESS; }else{ addActionError("你的用户名和密码不匹配"); return INPUT; } } public String getUsername() { return this.username; } public void setUsername(String username) { this.username = username; } public String getPassword() { return this.password; } public void setPassword(String password) { this.password = password; } public Map getSession(){ return session; } public void setSession(Map session){ this.session=session; } } 方法实现: package com.dao.impl; import java.util.List; import com.dao.UserDao; import com.model.*; /** * 还差个BaseDaoImpl类和UserDao接口 * @author Administrator * */ public class UserDaoImpl extends BaseDaoImpl implements UserDao{ //持久化类是Users: /*用于检查输入的用户名和密码是否和数据库中的一致*/ public Users isValidUser(String username,String password){ Users user=null; List<Users> list = super.search("from Users where username="""+username+""" and password="""+password+""""); if(list!=null&&list.size()>0){ user = list.get(0); } return user; } public void saveUser(Users user) { // TODO Auto-generated method stub } public List<Users> getAll(Class clazz) { // TODO Auto-generated method stub return null; } public Users getByName(String name) { // TODO Auto-generated method stub return null; } public void deleteByName(String name) { // TODO Auto-generated method stub } public List<Users> findByName(String name) { // TODO Auto-generated method stub return null; } public void update(Users user) { // TODO Auto-generated method stub } public Users isValidAdmin(String username, String password) { // TODO Auto-generated method stub Users user = null; List<Users> list = super.search("from Users where grade=""admin"" and username="""+username+""" and password="""+password+""""); if(list!=null&&list.size()>0){ user = list.get(0); } return user; } } jsp <%@ page contentType="text/html;charset=UTF-8" language="java"%> <%@ include file="/common/taglibs.jsp"%> <head> <title> 用户登录 </title> </head> <link href="images/myStyleClass.css" rel="stylesheet" type="text/css"> <body> <%@ include file="/common/header.jsp"%> <%-- <s:form action="test.jsp" method="post"> --%> <s:form action="UserLogin" > <!-- 已修改:以前是这个 --> <center> <table border="0" cellspacing="2" cellpadding="2" width="22%"> <tr> <s:actionerror /> </tr> <tr> <td width="60%"> <s:textfield name="username" label="用户"/> </td> </tr> <tr> <td width="60%"> <s:password name="password" label="密码"/> </td> </tr> <tr> <td colspan="2" > <s:submit name="submit" align="center" value="登录" theme="simple"></s:submit> <s:reset align="center" value="重置" theme="simple"></s:reset> </td> </tr> </table> </center> </s:form> <%@ include file="/common/footer.jsp"%> </body> |
|
37分 |
问题呢????
|
就是想问哪出问题了找不到资源啊 |
|
拦截器有拦截到不 |