There is a user's system that inevitably requires users' login and authentication. Today, you will learn how to log in in the system of the Spring architecture by analyzing the JPetStore from Spring.
1. First, start from the registered user, first look at the bean definition of the registered user in JPETSTORE-Servlet.xml. From the defined name, you can see that the following is the registered user: proty> < Ref bean = "accountvalidator" /> property> index value> property> bean> 1). Formview? Get it from the constructor of AccountformController, it is an editaccountform; 2). EDITOACCOUNTFORM.JSP is very chaotic, in fact, there is not much difficult understanding, the most important thing is that this form is both add new users, and editing user information. So it looks a bit messy.
2, add a new user, then look at how to log in, discover both related beans definitions in the jpetstore-servlet, as follows: print> bean> sign " value> property> bean> 1). The second bean is in runtime user input FORM of the username and password called SignonForm, for this parameterizableviewcontroller, in the document, this is the simplest controller, its role is to point to Controller instead of the JSP file in the run, just this.
2). Signonform.jsp, it is a simple form. It is the first bean, ie /shop/signon.do, and the most important thing to note is SignonForwardAction. Its main role is that forward to enter the username and password. On the page, where is this variable? Consider the following: list > Printy>