日期:2014-05-17 浏览次数:20736 次
<body> <div id="login"> <p id="login-top"> <fmt:message key="index.login.title" /> </p> <p class="login-input"> <fmt:message key="index.login.userName" /> <input type="text" id="userName" /> </p> <p class="login-input"> <fmt:message key="index.login.userPassword" /> <input type="password" id="userPassword" /> </p> <p id="login-buttom"> <input type="button" value="登录" id="btnOk"/> <input type="button" value="重置" id="btnCancel"/> </p> </div> </body>
$(document).ready(function() { $("#userName").val(""); $("#userPassword").val(""); $("#btnOk").click(function() { var url = "login.action"; var params = { userName : $("#userName").val(), userPassword : $("#userPassword").val() } $.post(url, params, function(data) { alert("11"); },"json"); }); $("#btnCancel").click(function() { $("#userName").val(""); $("#userPassword").val(""); }); });
<bean id="jwUserAction" class="com.sj.action.JwUserAction"> <property name="jwUserService" ref="jwUserService"></property> </bean>
<package name="ajax" extends="json-default"> <action name="login" class="jwUserAction" method="login"> <result type="json"> <param name="contentType">text/html</param> </result> </action> </package>
public class JwUserAction extends ActionSupport { private static final long serialVersionUID = 2495756323386561975L; private String userName; private String userPassword; private int result; private IJwUserService jwUserService; public String getUserName() { return userName; } public void setUserName(String userName) { this.userName = userName; } public String getUserPassword() { return userPassword; } public void setUserPassword(String userPassword) { this.userPassword = userPassword; } public IJwUserService getJwUserService() { return jwUserService; } public void setJwUserService(IJwUserService jwUserService) { this.jwUserService = jwUserService; } public int getResult() { return result; } public void setResult(int result) { this.result = result; } public String log