µÚÒ»·¶ÎÄÍø - רҵÎÄÕ·¶ÀýÎĵµ×ÊÁÏ·ÖÏíÆ½Ì¨

MyEclipse8.6°æµÄSSHʵÑé

À´Ô´£ºÓû§·ÖÏí ʱ¼ä£º2025/11/14 3:05:42 ±¾ÎÄÓÉloading ·ÖÏí ÏÂÔØÕâÆªÎĵµÊÖ»ú°æ
˵Ã÷£ºÎÄÕÂÄÚÈݽö¹©Ô¤ÀÀ£¬²¿·ÖÄÚÈÝ¿ÉÄܲ»È«£¬ÐèÒªÍêÕûÎĵµ»òÕßÐèÒª¸´ÖÆÄÚÈÝ£¬ÇëÏÂÔØwordºóʹÓá£ÏÂÔØwordÓÐÎÊÌâÇëÌí¼Ó΢ÐźÅ:xxxxxxx»òQQ£ºxxxxxx ´¦Àí£¨¾¡¿ÉÄܸøÄúÌṩÍêÕûÎĵµ£©£¬¸ÐлÄúµÄÖ§³ÖÓëÁ½⡣

public interface ActionManager {

/**

* ¸ù¾ÝÓû§Ãû£¬ÃÜÂëÑéÖ¤µÇ¼ÊÇ·ñ³É¹¦ * @param username µÇ¼ËùÊäÈëµÄÓû§Ãû * @param password µÇ¼µÄÃÜÂë */

Integer validLogin(String username , String password); }

2. ÔÚcom.service.impl°üÖд´½¨ÒµÎñÂß¼­²ã½Ó¿ÚµÄʵÏÖÀ࣬Èçͼ7.

ͼ7 ActionManagerʵÏÖ½Ó¿Ú

package com.service.impl;

import com.dao.UserDAO;

import com.domain.Users;

import com.service.ActionManager;

public class ActionManagerImpl implements ActionManager{

public Integer validLogin(String username, String password){

try

Users user = userDAO.findUserByNameAndPass(username, if (user!= null) { }

return user.getId();

{

private UserDAO userDAO;

public void setUserDAO(UserDAO userDAO) { }

this.userDAO = userDAO;

password);

}

catch (Exception e)

}

{

System.out.println(e.getMessage()); } }

return null;

ËÄ¡¢

¿ØÖƲãÉè¼ÆÓëʵÏÖ

1. ActionµÄ´´½¨

£¨1£©ÔÚcom. action°üÖд´½¨Action¡£Èçͼ8.

ͼ8 µÇ¼Action

// LoginActionÔ´ÂëÈçÏ£º

package com.action;

import com.service.ActionManager;

import com.opensymphony.xwork2.ActionSupport;

public class LoginAction extends ActionSupport {

public String execute() throws Exception {

}

Integer userId = mgr.validLogin(username, password);

if (userId != null) { }

return SUCCESS;

addActionError(\Óû§Ãû/ÃÜÂ벻ƥÅä\); return \; } else {

return \;

protected ActionManager mgr;

private String username; private String password;

private static final long serialVersionUID = 1L;

if(username.equals(\) || username == null){

}

public String getPassword() { }

public String getUsername() { }

public void setPassword(String password) { }

public void setUsername(String username) { }

this.username = username; this.password = password; return username; return password;

public void setMgr(ActionManager mgr) {

this.mgr = mgr;

}

public ActionManager getMgr() {

return mgr;

} }

2. Struts2¿ØÖÆÎļþºÍÊôÐÔÎļþµÄÅäÖà (1) actionµÄÅäÖÃ

ϵͳÉú³ÉµÄStruts.xmlÄ£°åΪ£º

//struts.xml

ÅäÖÃ×ÊÔ´×ÔºóµÄStruts.xmlΪ

//struts.xml

value=\ />

/next.jsp /index.jsp (2)

struts.properties

// struts.propertise struts.locale=zh_CN

struts.i18n.encoding=UTF-8 struts.objectFactory = spring

struts.objectFactory.spring.autoWire = name struts.multipart.parser=jakarta struts.action.extension=action struts.serve.static=true

struts.serve.static.browserCache=true

struts.enable.DynamicMethodInvocation = true struts.enable.SlashesInActionNames = false struts.tag.altSyntax=true struts.devMode = false struts.i18n.reload=false struts.ui.theme=xhtml

struts.ui.templateDir=template

#sets the default template type. Either ftl, vm, or jsp struts.ui.templateSuffix=ftl

struts.configuration.xml.reload=false

### Location of velocity.properties file. defaults to velocity.properties

struts.velocity.configfile = velocity.properties

### Comma separated list of VelocityContext classnames to chain to the StrutsVelocityContext struts.velocity.contexts =

### Location of the velocity toolbox struts.velocity.toolboxlocation=

### used to build URLs, such as the UrlTag struts.url.http.port = 80 struts.url.https.port = 443

### possible values are: none, get or all

ËÑË÷¸ü¶à¹ØÓÚ£º MyEclipse8.6°æµÄSSHʵÑé µÄÎĵµ
MyEclipse8.6°æµÄSSHʵÑé.doc ½«±¾ÎĵÄWordÎĵµÏÂÔØµ½µçÄÔ£¬·½±ã¸´ÖÆ¡¢±à¼­¡¢ÊղغʹòÓ¡
±¾ÎÄÁ´½Ó£ºhttps://www.diyifanwen.net/c7afga6azrj7yqpp85nax_4.html£¨×ªÔØÇë×¢Ã÷ÎÄÕÂÀ´Ô´£©
ÈÈÃÅÍÆ¼ö
Copyright © 2012-2023 µÚÒ»·¶ÎÄÍø °æÈ¨ËùÓÐ ÃâÔðÉùÃ÷ | ÁªÏµÎÒÃÇ
ÉùÃ÷ :±¾ÍøÕ¾×ðÖØ²¢±£»¤ÖªÊ¶²úȨ£¬¸ù¾Ý¡¶ÐÅÏ¢ÍøÂç´«²¥È¨±£»¤ÌõÀý¡·£¬Èç¹ûÎÒÃÇ×ªÔØµÄ×÷Æ·ÇÖ·¸ÁËÄúµÄȨÀû,ÇëÔÚÒ»¸öÔÂÄÚ֪ͨÎÒÃÇ£¬ÎÒÃǻἰʱɾ³ý¡£
¿Í·þQQ£ºxxxxxx ÓÊÏ䣺xxxxxx@qq.com
ÓåICP±¸2023013149ºÅ
Top