struts2 点登陆按钮没有反应 (请高人帮忙看看什么原因)
divLogin.jsp代码如下:
<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*"
errorPage="" %>
<%@ taglib uri="/struts-tags" prefix="struts" %>
<%@ taglib prefix="sx" uri="/struts-dojo-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<struts:head theme="xhtml"/>
<sx:head parseContent="true"/>
<div class="div" id="loginDiv">
<div id=errorDiv>
</div>
<struts:form name="divLoginForm" id="divLoginForm">
<struts:label label=" 请输入用户名密码:"></struts:label>
<struts:textfield name="username" label="账号" value="helloween"></struts:textfield>
<struts:password name="password" label="密码" value="1234" title="1234">
</struts:password>
<struts:url action="divLogin!login" id="divLoginUrl" >
</struts:url>
<struts:submit value="登录" formId="divLoginForm" theme="ajax" href="%{divLoginUrl}"
targets="loginSuccessDiv" executeScripts= "true" />
</struts:form>
</div>
<div id="loginSuccessDiv" class="div" style="display:none;">
</div>
divLoginAction.java代码如下:
package com.struts2.action;
import org.apache.struts2.ServletActionContext;
import com.opensymphony.xwork2.ActionSupport;
public class DivLoginAction extends ActionSupport{
private String username;
private String password;
public String execute()
{
return "input";
}
public String login()
{
if("helloween".equals(username)&& "1234".equals(password))
{
ServletActionContext.getRequest().getSession(true).setAttribute("username", username);
ServletActionContext.getRequest().setAttribute("status","success");
}
else
{
ServletActionContext.getRequest().setAttribute("status","failed");
}
return "script";
}
public String logout()
{
ServletActionContext.getRequest().getSession(true).removeAttribute("username");
ServletActionContext.getRequest().setAttribute("status","logout");
return "script";
}
}
divLoginScript.jsp代码如下:
<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" errorPage="" %>
<%@ taglib uri="/struts-tags" prefix="struts" %>
<struts:bean id="date" name="java.util.Date"></struts:bean>
<struts:if test="%{#request.status == 'success'}">
欢迎你,<struts:property value="#session.username"/>.登录时间:<struts:date name="%{#date}"/>
<struts:url action="divLogin!logout" id="divLogoutUrl"></struts:url>
<struts:a href="%{#divLogoutUrl}" theme="ajax" executeScript="true">
&n