Struts2能进入Action,但不执行里面包括execute的任何方法!!求帮助!!
login.jsp页
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@taglib prefix="s" uri="/struts-tags"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>登陆系统</title>
</head>
<body>
<%@include file="common/header.jsp"%>
<table width="780" align="center" background="<%=ctx%>/images/bodybg.jpg">
<tr>
<td>
<h6>请输入用户名和密码来登陆<br></h6>
<s:if test="tip!=null">
<div class="error">
<s:property value="tip"/>
</div>
</s:if>
<s:actionerror cssClass="error"/>
<s:form action="login.action" name="form1" method="execute">
<s:textfield name="username" label="用户名"/>
<s:password name="password" label="密码"/>
<tr>
<td colspan="2">
<s:submit value="登录" theme="simple"/>
<s:reset theme="simple" value="重置" />
</td>
</tr>
</s:form>
</td>
</tr>
</table>
<%@include file="common/footer.jsp"%>
</body>
</html>
<struts>
<constant name="struts.objectFactory" value="org.apache.struts2.spring.StrutsSpringObjectFactory"/>
<!-- <constant name="struts.enable.DynamicMethodInvocation" value="false" /> -->
<!-- 允许action的名字中出现"/" -->
<constant name="struts.enable.SlashesInActionNames" value="true"/>
<!-- 配置了系列常量 -->
<constant name="struts.custom.i18n.resources" value="mess"/>
<constant name="struts.i18n.encoding" value="UTF-8"/>
<package name="default" extends="struts-default" abstract="true">
<!-- 定义全局Result映射 -->
<global-results>
<result name="exception">/WEB-INF/jsp/error/error.jsp</result>
<!-- 定义login逻辑视图对应的视图资源 -->
<result name="login">/WEB-INF/jsp/login.jsp</result>
</global-results>
<global-exception-mappings>
<!-- 定义全局异常映射 -->
<exception-mapping result="exception" exception="java.lang.Exception" />
</global-exception-mappings>
</package>
<package name="custom-default" extends="default" namespace="/WEB-INF/jsp">
<action name="login" class="cn.RptSystem.web.action.LoginAction">
<result name="success">/WEB-INF/jsp/success.jsp</result>
<result name="input">/WEB-INF/jsp/login.jsp</result>
<result name="fail">/WEB-INF/jsp/login.jsp</result>
</action>
</package>
</struts>
public class LoginAction extends UserBaseAction {
//登录的用户名
private String username;
//登录的密码
private String password;
//处理登录后的提示信息
private String tip;
public String getUsername() {
return username;
}
public void setUsername(String username) {
System.out.println("username");
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getTip() {
return tip;
}
public void setTip(String tip) {
this.tip = tip;
}
//处理用户请求
public String execute() throws Exception {
//创建ActionContext实例
ActionContext ctx = ActionContext.getContext();
//调用业务逻辑方法来处理登录请求
int loginResult = userService.Login(getUsername(), getPassword());
System.out.println(getUsername());
System.out.println(getPassword());
if(loginResult == userService.LOGIN_SUCCESS) {
ctx.getSession().put(Constants.USER, username);
setTip("您已经成功登陆系统");
return Constants.LOGIN_SUCCESS;
} else { //用户名和密码不匹配
setTip("用户名/密码不匹配");
return Constants.LOGIN_FAIL;
}
}
}
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<display-name>RptSystem</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<!-- 通用配置开始 -->
<!-- 配置Spring配置文件的位置 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<!-- 加载多个Spring配置文件 -->
<param-value>
classpath:applicationContext.xml ,
classpath:cn/RptSystem/dao/applicationContext-hibernate.xml ,
classpath:cn/RptSystem/service/applicationContext-service.xml
</param-value>
</context-param>
<!-- 使用ContextLoaderListener初始化Spring容器 -->
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<!-- 通用配置结束 -->
<!-- 设置web环境上下文(方便JSP页面获取)开始 -->
<filter>
<filter-name>Set Context Path</filter-name>
<filter-class>cn.RptSystem.commons.web.filter.ContextPathFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>Set Context Path</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- 设置web环境上下文(方便JSP页面获取)结束 -->
<!-- 字符编码过滤器(防止乱码)开始 -->
<filter>
<filter-name>Set Character Encoding</filter-name>
<filter-class>
org.springframework.web.filter.CharacterEncodingFilter
</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>Set Character Encoding</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- 字符编码过滤器(防止乱码)结束 -->
<!-- Struts2.x前端控制器配置开始 -->
<!-- 定义Struts2的FilterDispathcer的Filter -->
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- Struts2.x前端控制器配置结束 -->
</web-app>