哪位大神可以将Struts2 AJAX实现的登录和注册功能的代码发给我?

qq_33200835 2016-06-27 09:33:32
急!!!哪位大神可以告诉我怎么做?或者将源代码直接告诉我!!!!
...全文
89 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
阳光越来越暖 2016-06-27
  • 打赏
  • 举报
回复
页面 <%@ 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"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> <script type="text/javascript" src="js/jquery-1.8.3.js"></script> <script type="text/javascript"> $(function(){ $("input[type=button]").click(function(){ var userName=$("input[type=text]").val(); var userPwd=$("input[type=password]").val(); $.ajax({ type : 'post', url : 'login?user.userName='+userName+'&user.userPwd='+userPwd, async : false, dataType : 'text', success : function(obj){ } }) }); }) </script> </head> <body> <form action="login"> <input type="text" name="userName"/> <br/> <input type="password" name="userPwd"/> <br/> <input type="button" value="登录"/> </form> </body> </html> action package cn.com.app; import com.opensymphony.xwork2.ActionSupport; public class Test extends ActionSupport{ public User user=new User(); public String login(){ System.out.println(user.toString()); return "login"; } } 实体对象 package cn.com.app; public class User { private String userName; private String userPwd; public String getUserName() { return userName; } public void setUserName(String userName) { this.userName = userName; } public String getUserPwd() { return userPwd; } public void setUserPwd(String userPwd) { this.userPwd = userPwd; } @Override public String toString() { return "User [userName=" + userName + ", userPwd=" + userPwd + "]"; } } struts.xml <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN" "http://struts.apache.org/dtds/struts-2.3.dtd"> <struts> <constant name="struts.ognl.allowStaticMethodAccess" value="true"></constant> <package name="helloWorld" extends="struts-default" > <action name="login" class="cn.com.app.Test" method="login"> <result name=""></result> </action> </package> </struts> 自己导入jquery
技术控_ 2016-06-27
  • 打赏
  • 举报
回复
靠.这个都要...
阳光越来越暖 2016-06-27
  • 打赏
  • 举报
回复
我可以给你写一个登录的

67,541

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧