How to build a Struts database application with landing pages and roles

zhaozj2021-02-16  58

How to build a Struts database application with landing pages and roles

[aims]

The goal of this example is to implement a user login application. Save user information with SQL Server 2000 database. Implement the user login page, user login verification, login check tag and other functions.

Define a field named "Users" table:

Enter some test data:

For example, the above data may have a role or multiple roles. For multiple characters, you can use multiple records to indicate that a record represents a role or a record represents a plurality of roles, each role is separated by ";".

[effect]

Welcome page:

login page:

The main menu page after the landing is completed:

If you do not log in but run the main menu page user query page, you will automatically go to the user login page, and no longer give a show.

[background knowledge]

[step]

This example is compared with the steps in the "Struts Database Application", in addition to a selection "Struts Database Application Template" with Land and Roles "when establishing a new project, another selection" empty struts database application template ", And in the JSP page, you need to check if the user has logged in. "", the other steps are exactly the same, so the same step details see "How to implement the Struts database application ".

1. Open the Visual Struts development environment:

Start JavaWebStudio.exe files from the desktop JavaWebstudio fast or bin directory launched the Visual Struts development environment of JavaWebStudio.

2. Create an "empty Struts database application template application" application:

Select the menu "File" - "New" - "New Project", pop up the new project dialog, as shown in Figure 1 below:

Select "Empty Struts Database Application Template" in the dialog box, enter "Logon", Package (Package ", and location (path path) in the project name, which is of course changed as needed. Finally, click the "OK" button to complete the establishment of the new project.

In the root of the Logon project, you contain four subdirectories and two files, which is the standard structure of the JavaWebStudio project, it is best not to change their default names, otherwise there will be problems.

Using the project generated by the Struts Database Application Template with Logging Page and Roles, the logon.jsp and logonaction.java file required for the user login, and also generates files for user login demo, where Index.htm It is a "landing" button, click the "Log" button to go to the Logon.jsp Enter the input page, the login input is completed and submit, and if you log in, go to the MainMenu.jsp main menu page. Add a label after the main menu page tag "" is used to check if the user has already logged in, where the ROLE property is used to specify the user role, which means that only the role is "system "The user can pass. If you have already logged in, you will continue to display the page, otherwise you will automatically go to the login page.

Logon.jsp file:

INDEX.HTM file:

MainMenu.jsp file:

3. Use the Struts Database Application File Wizard to establish a new application:

To click the right mouse button in the JavaWebStudio file manager, select the Struts Database Application File Wizard to enter the Struts File Wizard dialog box, or select the menu "file" - "Struts Database Application File Wizard" The Struts File Wizard dialog box.

Enter the "Useredit" file name in the filename input field under the Struts file wizard dialog jsp file, other files use the default settings. (1) Enter the file name:

(2) Import the field information of the SQL statement and the data table from the data source (field name, and field type):

(3) Select the desired table "User" from the data table.

It is important to note that the "Field information of the SQL statement and data table from the data source" and "Select the table from the data table" is merely generated to automatically generate SQL statements and read field information, here Complete can be manually entered directly, unrelated to the configuration of the database connection pool, below, and then configure the database connection pool separately.

Next, configure the database connection pool, and other property pages can be used by default, and the data connection configuration property page is directly turned directly.

(4) JSPOUT property page settings:

The setting of the JSPOUT property page is the only step in the "How to Implement Struts Database Application", which is the core content of this example. As can be seen from the figure, we have to do it just to add the "Record Operation" selection in the settings of the "Record Operation" selection item.

(5) Configure the database connection pool:

Here you need to note that the user login is also used to use this database connection configuration.

(6) Plus the user login check tab in the newly generated JSP file :

The newly generated JSP file has three, query conditions Enter file useerEdit.jsp, add new record input files UserEditInsert.jsp and query results display file useritout.jsp. Add the user login check tag after the tag of these three files, respectively.

4, project file structure

Project directory structure analysis See "How to achieve the simplest struts program", this Struts database application file wizard automatically generates six files, where the web directory is input, output two JSP files, the SRC directory is a Java file. All program source code is automatically generated by the file wizard except that the file name is automatically generated, and all configurations are also automatically completed.

Refresh the JavaWebStudio file manager, then the three files are automatically generated in the web directory, which is useeredit.jsp and useeredit.jsp and useritinsert.jsp, the former is an input JSP file, the middle is output JSP file, the latter is adding a record Page file; SRC / EMPTYPRJ directory automatically generates four files, which are useeredit action.java, useeredit form.java, the former is an action file, the latter is a formaction file; there is a database operation file Useredit.java and Usereditdao. Java, the former is used to save the bean recorded by the data table, and the latter is a database operation DAO file.

4.1, modify the DAO file:

If the data is selected, SQL Server 2000, you need to put the following code in the DAO file:

// Please join the down with SQL Server:

//con.setautoCommit (true);

// SQL Server

Both rewritten into the following code:

// Please join the down with SQL Server:

Con.SetAutocommit (True); // Note !! This is this line, it turned out to be annotated, now you have to get your annotation !!

// SQL Server

Through the above rewriting, the SQL Server 2000 can be recorded, deleted, and adding the SQL Server 2000 by JDBC. 4.2 Join the login identification label on the place where the user login identification is required

(1) Useredit.jsp file:

Plus tag before

<% @ page contenttype = "text / html; charset = GB2312" Language = "java"%>

<% @ Taglib Uri = "/ Web-INF / STRUTS-Bean.tld" prefix = "bean"%>

<% @ Taglib URI = "/ Web-INF / STRUTS-HTML.TLD" prefix = "html"%>

<% @ Taglib URI = "/ Web-INF / STRUTS-LOGIC.TLD" prefix = "logic"%>

<% @ Taglib URI = "/ Web-INF / STRUTS-TEMPLATE.TLD" prefix = "template"%>

</ title></p> <p><HTML: BASE /></p> <p></ hEAD></p> <p><app: checklogon role = "system" /></p> <p><body bgcolor = "white"></p> <p><html: form action = "/ usereditaction.do?action=search&search=search&pression=null" Method = "post"></p> <p>Please enter the username you want to find: <html: text property = "username" /></p> <p><html: Submit value = "Find" /></p> <p><html: reset value = "rewrite" /></p> <p></ html: form></p> <p><html: form action = "useereditaction.do?action=search&pression=null" Method = "post"></p> <p><html: submit value = "All Display" /></p> <p></ html: form></p> <p></ body></p> <p></ html: html></p> <p>4.3 Join a new menu item "User Check" in the left page of the MainMenu.jsp Main Menu page Left.htm:</p> <p>The added code is mainly: <a href="ustit.jsp" target=ma all users query </a></p> <p>5, compile, start the server, run:</p> <p>Compile the project and start the server by the buttons on the toolbar, then open index.htm and run index.htm through the "Run" button on the toolbar and enter the corresponding data:</p> <p>Click "Login":</p> <p>Enter the correct username and password, select "Send", go to the main menu page: If you do not log in, run the mainmenu.jsp main menu page or the useerEdit.jsp Query page, will automatically go to the user login page, not here Reemptory.</p> <p>Also, if the user doesn't have this, I can't log in to the page.</p> <p>Through the above steps, the estimated target function is achieved.</p> <p>[Program source code]</p> <p>Compared with "How to Implement Struts Database Applications", this example is mainly a logon.jsp, logonaction.java file that users need to log in, and custom label files used to check if the user has logged in Checklogontag.java, due to Logon The .jsp file does not have a special place, so it is not listed here.</p> <p>LogonAction.java file:</p> <p>Package EmptyPRJ;</p> <p>Import emptyprj.jdbc.util.ConnectionPool;</p> <p>Import java.util.locale;</p> <p>Import javax.servlet.http.httpservletRequest;</p> <p>Import javax.servlet.http.httpsession;</p> <p>Import javax.servlet.http.httpservletResponse;</p> <p>Import org.apache.commons.logging.log;</p> <p>Import org.apache.commons.logging.logfactory;</p> <p>Import org.apache.struts.Action.action;</p> <p>Import org.apache.struts.Action.Actionerror;</p> <p>Import org.apache.struts.Action.Actionerro;</p> <p>Import org.apache.struts.Action.actionform;</p> <p>Import org.apache.struts.Action.actionForward;</p> <p>Import org.apache.struts.action.actionmapping;</p> <p>Import org.apache.struts.util.moduleException;</p> <p>Import org.apache.struts.util.MessageResources;</p> <p>Import org.apache.commons.beanutils.propertyUtils;</p> <p>Import java.sql.connection;</p> <p>Import java.sql.preparedStatement;</p> <p>Import java.sql.resultset;</p> <p>Import java.sql.sqlexception;</p> <p>Import java.util.hashmap;</p> <p>Import java.util.collection;</p> <p>/ **</p> <p>* Implementation of <strong> action </ strong> That Validates a User Logon.</p> <p>*</p> <p>* @Author craig R. McClanahan</p> <p>* @version $ revision: 1.14 $ $ date: 20</p> <p>03/01/11</p> <p>03:08:23 $</p> <p>* /</p> <p>Public Final Class LogonAction Extends Action {</p> <p>/ / -------------------------------------------------------------------------------------------- ----- Instance Variables</p> <p>/ **</p> <p>* The <code> log </ code> instance for this application.</p> <p>* /</p> <p>Private log log =</p> <p>Logfactory.getlog ("Org.apache.struts.WebApp.example"); Private ConnectionPool Pool;</p> <p>Public logonAction () {</p> <p>Pool = connectionPool.getInstance ();</p> <p>}</p> <p>/ / -------------------------------------------------------------------------------------------- --------- Public Methods</p> <p>/ **</p> <p>* Process The Specified Http Request, and Create The Corresponding HTTP</p> <p>* Response (or Forward to another Web Component That Will Create IT).</p> <p>* Return AN <code> Actionforward </ code> Instance Describing Where and how</p> <p>* Control SHOULD BE Forwarded, or <code> Null </ code> if The Response HAS</p> <p>* Already Been Completed.</p> <p>*</p> <p>* @Param mapping the actionMapping use to select this instance</p> <p>* @Param Form The Optional Actionform Bean for this Request (if any)</p> <p>* @Param Request The Http Request WE Are Processing</p> <p>* @Param Response The Http Response We Are Creating</p> <p>*</p> <p>* @Exception Exception if Business Logic THROWS AN Exception</p> <p>* /</p> <p>Public ActionForward Execute (ActionMapping Mapping,</p> <p>Actionform Form,</p> <p>HTTPSERVLETREQUEST REQUEST,</p> <p>Httpservletresponse response</p> <p>Throws exception {</p> <p>// Extract Attributes We Will Need</p> <p>Locale locale = getLocale (request);</p> <p>MessageResources Messages = GetResources (Request);</p> <p>// Validate the Request Parameters Specified by The User</p> <p>ActionerroS Errors = new actionerrors ();</p> <p>String UserName = (String)</p> <p>PropertyUtils.getsimpleProperty (Form, "UserName");</p> <p>String password = (string)</p> <p>PropertyUtils.getsimpleProperty (Form, "Password");</p> <p>String getUsername = Checkuser (username, password);</p> <p>IF ("" .equals (getusername))</p> <p>{</p> <p>Errors.Add (actionerroS.Global_ERROR,</p> <p>New ActionError ("Error.Password.mismatch))));</p> <p>}</p> <p>GetUsername = username getusername;</p> <p>// Report Any Errors We Have Discovered Back to The Original Formif (! Errors.Isempty ()) {</p> <p>SaveerRors (Request, Errors);</p> <p>Mapping.getInputForward ());</p> <p>}</p> <p>// Save Our Logged-in User In the session</p> <p>HttpSession session = request.getations ();</p> <p>Session.SetaTRibute (constants.user_</p> <p>Key</p> <p>GetUsername;</p> <p>IF (log.Indebugeload ()) {</p> <p>Log.debug ("LogonAction: User '" UserName </p> <p>"'logged on in session" session.getID ());</p> <p>}</p> <p>// Remove the Obsolete form bean</p> <p>IF (mapping.getattribute ()! = null) {</p> <p>IF ("REQUEST" .Equals (mapping.getscope ()))))</p> <p>Request.Removettribute (mapping.getattribute ());</p> <p>Else</p> <p>Session.Removettribute (mapping.getattribute ());</p> <p>}</p> <p>// forward control to the specified surcess</p> <p>URI</p> <p>Mapping.Findforward ("Success"));</p> <p>}</p> <p>/ / -------------------------------------------------------------------------------------------- ------ Protected Methods</p> <p>/ **</p> <p>* Look Up The User, throwing an exception to simulate business logic</p> <p>* Rule Exceptions.</p> <p>*</p> <p>* @Param Database Database in Which to Look Up The User</p> <p>* @Param Username UserName Specified On The Logon Form</p> <p>*</p> <p>* @Exception ModuleException if a business logic rule is violated</p> <p>* /</p> <p>Public String Checkuser (String UserName, String Password)</p> <p>{</p> <p>Connection con = NULL;</p> <p>Try</p> <p>{</p> <p>Con = pool.getConnection ();</p> <p>String SQL = "SELECT * from dbo.users where username =?</p> <p>AND</p> <p>PASSWORD =? ";</p> <p>PreparedStatement PS = NULL;</p> <p>ResultSet RS = NULL;</p> <p>Try {</p> <p>IF (con?isclosed ()) {</p> <p>Throw new IllegalStateException ("Error.con.isClosed");</p> <p>}</p> <p>PS = con.preparestatement (SQL);</p> <p>ps.setstring (1, username);</p> <p>Ps.setstring (2, password);</p> <p>RS = ps.executeQuery ();</p> <p>String Returnstr = ""</p> <p>While (rs.next ())</p> <p>{</p> <p>Returnstr = ";" rs.getstring ("role");}</p> <p>Return Returnstr;</p> <p>} catch (sqlexception e) {</p> <p>E.PrintStackTrace ();</p> <p>Throw new runtimeException ("Error.ps.executeQuery);</p> <p>} finally {</p> <p>Try {</p> <p>IF (PS! = NULL)</p> <p>ps.close ();</p> <p>IF (rs! = null)</p> <p>Rs.close ();</p> <p>} catch (sqlexception e) {</p> <p>E.PrintStackTrace ();</p> <p>Throw new runtimeException ("error.rs.close");</p> <p>}</p> <p>}</p> <p>}</p> <p>Catch (SQLException E)</p> <p>{</p> <p>E.PrintStackTrace ();</p> <p>Throw new runtimeException ("Unable to get connection.");</p> <p>}</p> <p>Finally</p> <p>{</p> <p>Try</p> <p>{</p> <p>IF (con! = null)</p> <p>C. close ();</p> <p>}</p> <p>Catch (SQLException E)</p> <p>{</p> <p>Throw new runtimeException (E.GetMessage ());</p> <p>}</p> <p>}</p> <p>}</p> <p>}</p> <p>Checklogontag.java file:</p> <p>Used to check if the user has logged in the custom tag original code.</p> <p>Package EmptyPRJ;</p> <p>Import java.io.ioException;</p> <p>Import javax.servlet.servletException;</p> <p>Import javax.servlet.http.httpsession;</p> <p>Import org.apache.struts.util.RequestUtils;</p> <p>Import org.apache.struts.util.responseutils;</p> <p>Import javax.servlet.jsp.jspexception;</p> <p>Import javax.servlet.jsp.tageXt.tagsupport;</p> <p>Import org.apache.struts.config.moduleconfig;</p> <p>/ **</p> <p>* Check for a valid user logged on in the current session. If there is no</p> <p>* Such User, Forward Control to the Logon Page.</p> <p>*</p> <p>* @Author craig R. McClanahan</p> <p>* @Author Marius Barduta</p> <p>* @version $ revision: 1.8 $ $ date: 20</p> <p>03/04/09</p> <p>02:28:24 $</p> <p>* /</p> <p>Public final class checklogontag outs tagsupport {</p> <p>Private string role = "";</p> <p>/ / -------------------------------------------------------------------------------------------- --- Instance Variables</p> <p>/ **</p> <p>* The key of the session-scope bean we look for.</p> <p>* /</p> <p>Private string name = constants.user_</p> <p>Key</p> <p>;</p> <p>/ **</p> <p>* The page to which we should forward for the user to log on.</p> <p>* /</p> <p>Private string Page = "/logon.jsp";</p> <p>/ / -------------------------------------------------------------------------------------------- ----------- Properties / **</p> <p>* Return the bean name.</p> <p>* /</p> <p>Public string getname () {</p> <p>Return (this.name);</p> <p>}</p> <p>/ **</p> <p>* Set the bean name.</p> <p>*</p> <p>* @Param Name the New Bean Name</p> <p>* /</p> <p>Public void setname (String name) {</p> <p>THIS.NAME = Name;</p> <p>}</p> <p>/ **</p> <p>* Return The Forward Page.</p> <p>* /</p> <p>Public string getpage () {</p> <p>Return (this.page);</p> <p>}</p> <p>/ **</p> <p>* SET The Forward Page.</p> <p>*</p> <p>* @Param Page The New Forward Page</p> <p>* /</p> <p>Public void setpage (string page) {</p> <p>THIS.PAGE = Page;</p> <p>}</p> <p>Public void setrole (String newrole)</p> <p>{</p> <p>Role = newrole;</p> <p>}</p> <p>Public String getRole ()</p> <p>{</p> <p>Return role;</p> <p>}</p> <p>/ / -------------------------------------------------------------------------------------------- ------- Public Methods</p> <p>/ **</p> <p>* Defer we checking untric the end of this tag is encountered.</p> <p>*</p> <p>* @Exception JSPEXCEPTION IF A JSP Exception Has Occurre</p> <p>* /</p> <p>Public int desartTartTag () throws jspexception {</p> <p>Return (SKIP_BODY);</p> <p>}</p> <p>/ **</p> <p>* Performur Logged-in User CHECK BY LOOKING FOR THE EXISTENCE OF</p> <p>* a session scope bean under the specified name. if this bean is not</p> <p>* Present, Control is Forwarded to the specified logon page.</p> <p>*</p> <p>* @Exception JSPEXCEPTION IF A JSP Exception Has Occurre</p> <p>* /</p> <p>PUBLIC INT DOENDTAG () THROWS JSPEXCEPTION {</p> <p>// Is there a valid user logged on?</p> <p>Boolean Valid = False;</p> <p>HttpSession session = pageContext.getations ();</p> <p>IF ((session! = null) && (session.getattribute (name)! = NULL)) {</p> <p>String str = "null";</p> <p>String getUsername = "null";</p> <p>String getrole = "null";</p> <p>Try</p> <p>{</p> <p>Str = (string) session.getattribute (name);</p> <p>GetUsername = str.substring (0, str.indexof (";"));</p> <p>Getrole = str.substring (Str.Indexof (";") 1, str.length ()). Trim ();</p> <p>IF (Checkrole (Role, Getrole) {</p> <p>VALID = TRUE;</p> <p>}</p> <p>}</p> <p>Catch (Exception E) {</p> <p>Valid = false;</p> <p>}</p> <p>/ *</p> <p>Responseutils.write (PageContext, STR);</p> <p>Responseutils.write (PageContext, "<p> </ p>");</p> <p>Responseutils.write (pageContext, getusername);</p> <p>Responseutils.write (PageContext, "<p> </ p>");</p> <p>ResponseUtils.write (pageContext, getrole);</p> <p>Responseutils.write (PageContext, "<p> </ p>");</p> <p>Responseutils.write (PageContext, Role);</p> <p>* /</p> <p>}</p> <p>// Return Skip_body;</p> <p>// forward control based on the results</p> <p>IF (Valid) {</p> <p>Return (EVAL_</p> <p>Page</p> <p>);</p> <p>} else {</p> <p>ModuleConfig CONFIG =</p> <p>(ModuleConfig) PageContext.getServletContext (). GetaTtribute (</p> <p>Org.apache.struts.globals.module_</p> <p>Key</p> <p>);</p> <p>Try {</p> <p>PageContext.Forward (config.getprefix () page);</p> <p>} catch (servletexception e) {</p> <p>Throw new JSPEXCEPTION (E.TOString ());</p> <p>} catch (ioexception e) {</p> <p>Throw new JSPEXCEPTION (E.TOString ());</p> <p>}</p> <p>Return (SKIP_</p> <p>Page</p> <p>);</p> <p>}</p> <p>}</p> <p>/ **</p> <p>* Release Any acquired resources.</p> <p>* /</p> <p>Public void release () {</p> <p>Super.release ();</p> <p>THIS.NAME = Constants.user_</p> <p>Key</p> <p>;</p> <p>THIS.PAGE = "/logon.jsp";</p> <p>THIS.ROLE = "";</p> <p>}</p> <p>Public Boolean Checkrole (String Role, String Getrole)</p> <p>{</p> <p>Getrole = getrole.trim () ;;</p> <p>Role = role.trim ();</p> <p>//if (""".equals(Getrole ))Return False;</p> <p>String thisrole;</p> <p>While (Getrole.Indexof (";")> 1)</p> <p>{</p> <p>Thisrole = getrole.substring (0, getrole.indexof (";")). TRIM ();</p> <p>Getrole = getrole.substring (Getrole.Indexof (";") 1, getrole.length ()). Trim ();</p> <p>IF (Role.Equals (thisrole))</p> <p>{</p> <p>Return True;</p> <p>}</p> <p>}</p> <p>Thisrole = getrole;</p> <p>IF (Role.Equals (thisrole))</p> <p>{</p> <p>Return True;</p> <p>}</p> <p>Return False;</p> <p>}</p> <p>}</p> <p>[Extension]</p> <p>The above is the <app: checklogon role = "system" /> tab checks if the user has logged in and the user contains the user role specified by the ROLE property, where only one role can be placed, if you want to place multiple characters, how to deal with? Others are very simple. As long as the above procedures are improved as follows:</p> <p>1, the label uses <app: checklogon role = "role 1"; "Role 2"; "Role 3" />. Each role is separated by ";", indicating that only one of the characters in the role specified by this ROLE property can be passed.</p> <p>2. Change the checkrole () function of the checklogontag.java file as follows:</p> <p>Package EmptyPRJ;</p> <p>Import java.io.ioException;</p> <p>Import javax.servlet.servletException;</p> <p>Import javax.servlet.http.httpsession;</p> <p>Import org.apache.struts.util.RequestUtils;</p> <p>Import org.apache.struts.util.responseutils;</p> <p>Import javax.servlet.jsp.jspexception;</p> <p>Import javax.servlet.jsp.tageXt.tagsupport;</p> <p>Import org.apache.struts.config.moduleconfig;</p> <p>Import org.apache.struts.global;</p> <p>Import org.apache.struts.util.MessageResources;</p> <p>Import org.apache.struts.Action.Actionerror;</p> <p>Import org.apache.struts.Action.Actionerro;</p> <p>Public final class checklogontag outs tagsupport {</p> <p>Private string role = "";</p> <p>Private string name = constants.user_</p> <p>Key</p> <p>;</p> <p>Private string Page = "/logon.jsp";</p> <p>Public string getname () {</p> <p>Return (this.name);</p> <p>}</p> <p>Public void setname (String name) {</p> <p>THIS.NAME = Name;</p> <p>}</p> <p>Public string getpage () {</p> <p>Return (this.page);</p> <p>}</p> <p>Public void setpage (string page) {</p> <p>THIS.PAGE = Page;</p> <p>}</p> <p>Public void setrole (String newrole)</p> <p>{</p> <p>Role = newrole;</p> <p>}</p> <p>Public String getRole ()</p> <p>{</p> <p>Return role;</p> <p>}</p> <p>Public int desartTartTag () throws jspexception {</p> <p>Return (SKIP_BODY);</p> <p>}</p> <p>PUBLIC INT DOENDTAG () THROWS JSPEXCEPTION {</p> <p>// Is there a valid user logged on?</p> <p>Boolean Valid = False;</p> <p>HttpSession session = pageContext.getations ();</p> <p>IF ((session! = null) && (session.getattribute (name)! = NULL)) {</p> <p>String str = "null";</p> <p>String getUsername = "null"; string getrole = "null";</p> <p>Try</p> <p>{</p> <p>Str = (string) session.getattribute (name);</p> <p>GetUsername = str.substring (0, str.indexof (";"));</p> <p>Getrole = str.substring (Str.Indexof (";") 1, str.length ()). Trim ();</p> <p>If (checkrole (role, getrole) // role is the role specified by the label, GETROLE is the user role read from the database.</p> <p>{</p> <p>VALID = TRUE;</p> <p>}</p> <p>}</p> <p>Catch (Exception E) {</p> <p>Valid = false;</p> <p>}</p> <p>/ *</p> <p>Responseutils.write (PageContext, STR);</p> <p>Responseutils.write (PageContext, "<p> </ p>");</p> <p>Responseutils.write (pageContext, getusername);</p> <p>Responseutils.write (PageContext, "<p> </ p>");</p> <p>ResponseUtils.write (pageContext, getrole);</p> <p>Responseutils.write (PageContext, "<p> </ p>");</p> <p>Responseutils.write (PageContext, Role);</p> <p>* /</p> <p>}</p> <p>// Return Skip_body;</p> <p>// forward control based on the results</p> <p>IF (Valid) {</p> <p>Return (EVAL_</p> <p>Page</p> <p>);</p> <p>} else {</p> <p>ActionerroS Errors = new actionerrors ();</p> <p>Errors.Add (actionerroS.Global_ERROR,</p> <p>New ActionError ("Error.Password.mismatch))));</p> <p>PageContext.getRequest (). SetAttribute (Globals.Error_</p> <p>Key</p> <p>, Errors); // Save an error message</p> <p>ModuleConfig CONFIG =</p> <p>(ModuleConfig) PageContext.getServletContext (). GetaTtribute (</p> <p>Org.apache.struts.globals.module_</p> <p>Key</p> <p>);</p> <p>Try {</p> <p>PageContext.Forward (config.getprefix () page);</p> <p>} catch (servletexception e) {</p> <p>Throw new JSPEXCEPTION (E.TOString ());</p> <p>} catch (ioexception e) {</p> <p>Throw new JSPEXCEPTION (E.TOString ());</p> <p>}</p> <p>Return (SKIP_</p> <p>Page</p> <p>);</p> <p>}</p> <p>}</p> <p>/ **</p> <p>* Release Any acquired resources.</p> <p>* /</p> <p>Public void release () {</p> <p>Super.release ();</p> <p>THIS.NAME = Constants.user_</p> <p>Key</p> <p>;</p> <p>THIS.PAGE = "/logon.jsp";</p> <p>THIS.ROLE = "";</p> <p>}</p> <p>Public Boolean Checkrole (String Role, String Getrole) // Role is the role specified by the label, and getRole is the user role that is read from the database. {</p> <p>Getrole = getrole.trim () ;;</p> <p>Role = role.trim ();</p> <p>//if (""".equals(Getrole ))Return False;</p> <p>String thisrole;</p> <p>Role = ";" Role ";";</p> <p>While (Getrole.Indexof (";")> 1)</p> <p>{</p> <p>Thisrole = getrole.substring (0, getrole.indexof (";")). TRIM ();</p> <p>Getrole = getrole.substring (Getrole.Indexof (";") 1, getrole.length ()). Trim ();</p> <p>Thisrole = ";" THISROLE ";";</p> <p>IF (Role.Indexof (thisrole, 0)> - 1)</p> <p>{</p> <p>Return True;</p> <p>}</p> <p>}</p> <p>Thisrole = getrole;</p> <p>Thisrole = ";" THISROLE ";";</p> <p>IF (Role.Indexof (thisrole, 0)> - 1)</p> <p>{</p> <p>Return True;</p> <p>}</p> <p>Return False;</p> <p>}</p> <p>}</p></div><div class="text-center mt-3 text-grey"> 转载请注明原文地址:https://www.9cbs.com/read-16735.html</div><div class="plugin d-flex justify-content-center mt-3"></div><hr><div class="row"><div class="col-lg-12 text-muted mt-2"><i class="icon-tags mr-2"></i><span class="badge border border-secondary mr-2"><h2 class="h6 mb-0 small"><a class="text-secondary" href="tag-2.html">9cbs</a></h2></span></div></div></div></div><div class="card card-postlist border-white shadow"><div class="card-body"><div class="card-title"><div class="d-flex justify-content-between"><div><b>New Post</b>(<span class="posts">0</span>) </div><div></div></div></div><ul class="postlist list-unstyled"> </ul></div></div><div class="d-none threadlist"><input type="checkbox" name="modtid" value="16735" checked /></div></div></div></div></div><footer class="text-muted small bg-dark py-4 mt-3" id="footer"><div class="container"><div class="row"><div class="col">CopyRight © 2020 All Rights Reserved </div><div class="col text-right">Processed: <b>0.045</b>, SQL: <b>9</b></div></div></div></footer><script src="./lang/en-us/lang.js?2.2.0"></script><script src="view/js/jquery.min.js?2.2.0"></script><script src="view/js/popper.min.js?2.2.0"></script><script src="view/js/bootstrap.min.js?2.2.0"></script><script src="view/js/xiuno.js?2.2.0"></script><script src="view/js/bootstrap-plugin.js?2.2.0"></script><script src="view/js/async.min.js?2.2.0"></script><script src="view/js/form.js?2.2.0"></script><script> var debug = DEBUG = 0; var url_rewrite_on = 1; var url_path = './'; var forumarr = {"1":"Tech"}; var fid = 1; var uid = 0; var gid = 0; xn.options.water_image_url = 'view/img/water-small.png'; </script><script src="view/js/wellcms.js?2.2.0"></script><a class="scroll-to-top rounded" href="javascript:void(0);"><i class="icon-angle-up"></i></a><a class="scroll-to-bottom rounded" href="javascript:void(0);" style="display: inline;"><i class="icon-angle-down"></i></a></body></html><script> var forum_url = 'list-1.html'; var safe_token = '8DQIeXSf079g4CRowhz1QH7SsszOHpLp_2F_2BPfJXxjl5fxsJA9SILBuxpYnTo_2B_2Bc3IVWZYTJiBJuu6y3sEXT16Nw_3D_3D'; var body = $('body'); body.on('submit', '#form', function() { var jthis = $(this); var jsubmit = jthis.find('#submit'); jthis.reset(); jsubmit.button('loading'); var postdata = jthis.serializeObject(); $.xpost(jthis.attr('action'), postdata, function(code, message) { if(code == 0) { location.reload(); } else { $.alert(message); jsubmit.button('reset'); } }); return false; }); function resize_image() { var jmessagelist = $('div.message'); var first_width = jmessagelist.width(); jmessagelist.each(function() { var jdiv = $(this); var maxwidth = jdiv.attr('isfirst') ? first_width : jdiv.width(); var jmessage_width = Math.min(jdiv.width(), maxwidth); jdiv.find('img, embed, iframe, video').each(function() { var jimg = $(this); var img_width = this.org_width; var img_height = this.org_height; if(!img_width) { var img_width = jimg.attr('width'); var img_height = jimg.attr('height'); this.org_width = img_width; this.org_height = img_height; } if(img_width > jmessage_width) { if(this.tagName == 'IMG') { jimg.width(jmessage_width); jimg.css('height', 'auto'); jimg.css('cursor', 'pointer'); jimg.on('click', function() { }); } else { jimg.width(jmessage_width); var height = (img_height / img_width) * jimg.width(); jimg.height(height); } } }); }); } function resize_table() { $('div.message').each(function() { var jdiv = $(this); jdiv.find('table').addClass('table').wrap('<div class="table-responsive"></div>'); }); } $(function() { resize_image(); resize_table(); $(window).on('resize', resize_image); }); var jmessage = $('#message'); jmessage.on('focus', function() {if(jmessage.t) { clearTimeout(jmessage.t); jmessage.t = null; } jmessage.css('height', '6rem'); }); jmessage.on('blur', function() {jmessage.t = setTimeout(function() { jmessage.css('height', '2.5rem');}, 1000); }); $('#nav li[data-active="fid-1"]').addClass('active'); </script>