第一范文网 - 专业文章范例文档资料分享平台

MyEclipse8.6版的SSH实验

来源:用户分享 时间:2025/5/29 21:39:13 本文由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