selle--Registered Users

Source: Internet
Author: User

1.

<action name= "Save" class= "Saveuseraction" ><!--name is the name that is called on the page class is the ID of appconf of an action in Material.xml-- ><!--<result name= "Success"  type= "redirect" >${url}</result>--><result name= "Success" >/web-inf/jsp/interim.jsp</result><result name= "fail" >/WEB-INF/jsp/register.jsp</result> <result name= "Error" >/WEB-INF/jsp/register.jsp</result></action>

2. Register a new user, care about 3 service, users, shopping cart, points!

Through the mailbox (user name) to the DB query to see if there is no use, use the direct jump to the error page,

Omit Setter/getter method public class Saveuseraction extends Selleckactionsupport {private static final long Serialversionuid = 1l;private userservice userservice;private cartservice cartservice;private pointservice pointService;private Integer Id;private string Username;private string password;private string name;private Timestamp createtime;private userdto User ;p rivate string Url;public string Execute () {Timestamp ts = new Timestamp (new Java.util.Date (). GetTime ()); User.setsource ("Selleckbio");//user source User.setcreatetime (TS);//creation time string pwdtemp = User.getpassword (); User.setpassword ( Md5maker.getmd5string (pwdtemp)); User.setlogincount (0);//Login number User.setlastlogin (TS);//Last Login Time User.setlevel ("1") ; StringBuffer hql = new StringBuffer ("SELECT count (userdto.id) from Userdto userdto where userdto.email= '"); Hql.append ( User.getemail (). Replace ("'", "" ")). Append (" ' "); int recan = USERSERVICE.COUNTHQL (hql.tostring ()); if (recan>0) { This.addactionmessage (rb.getstring ("emailused")); return ERROR;} id = UserserviCe.create (user); if (id! = 0) {User.setid (ID); Actioncontext Actioncontext = Actioncontext.getcontext ();   HttpServletRequest request=servletactioncontext.getrequest (); HttpSession HttpSession = Request.getsession (true); String sessionId = Httpsession.getid (); Map session = Actioncontext.getsession (); User.setpassword (pwdtemp); user = Userservice.auth (user); Cartservice.getbackfromsession (User.getid (), sessionId), if (Session.get (sessionId)!=null) {Session.put (User.getid (). ToString (), (String) Session.get (sessionId)); Session.remove (sessionId); Session.put (Constants.sessionid,user); String url_session = (string) actioncontext.getcontext (). GetSession (). Get ("Urlref"); if (url_session!=null&& !url_session.equals ("")) {if (Url_session.indexof ("addcart.jhtml")!=-1 | | Url_session.indexof ("checkout.jhtml")!=-1) {url_session= "/cart/checkout.jhtml";//url_session.replace ("AddCart", "Checkout");} url = url_session.tostring ();} String ServerPort = (Request.getserverport () + ""). Equals ("+")? "": (":" + REQUEST.GEtserverport ()); if (url!=null) {if (Url.equals ("") | | Url.equals ("http://" +request.getservername () +serverport+ "/login.html")) {URL = "/welcome.html";}} Creatpoint (user); return SUCCESS;} else {return FAIL;}} /** * Registration successfully added score record * @param user */private void Creatpoint (userdto user) {pointdto pointdto = new Pointdto ();p ointdto.se Taction ("Register");D ateformat formatdate = new SimpleDateFormat ("Yyyy/mm/dd hh:mm:ss");p ointdto.setadddate ( Formatdate.format (new Date ()));//date is a string type Pointdto.setdescription ("");p Ointdto.setimageno (""); Pointdto.setimagetype ("");p Ointdto.setorderno ("");p Ointdto.setpoint ("");p ointdto.setuserdto (user); Pointservice.create (Pointdto);}}

selle--Registered Users

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.