Struct2
------------------------------------------------------------web.xml ------------------------------------------------------------------
web.xml 中的配置
--------------------------------------------------------------------Structs.xml ---------------------------------------------------------
Structs.xml
Structs.xml 放在src 根目录下
以下是子文件 也放在src 根目录下
struts-use.xml
struts-note.xml
struts-friend.xml
struts-art.xml
Structs.xml
中的详细配置
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
-----------------------------------------------struts-use.xml文件 详细配置 案例----------------------------------------------
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
method="checkLogin" >
method="saveUser" >
-------------------------------------com.isoftstone.xiaonei.use.web.action.LoignAction-----------------------------------
package com.isoftstone.xiaonei.use.web.action;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts2.interceptor.ServletRequestAware;
import com.isoftstone.xiaonei.pojo.Users;
import com.isoftstone.xiaonei.use.service.IUserService;
import com.isoftstone.xiaonei.use.service.impl.UserService;
import org.apache.commons.logging.*;
/**
*
* @author ���յ�
* @����ʱ�䣺Jun 29, 2010 2:37:59 PM
* @��Ŀ��xiaonei
* @�ļ���LoignAction.java
* @����com.isoftstone.xiaonei.use.web.action
*/
public class LoignAction implements ServletRequestAware {
Log log=LogFactory.getLog("loginlog");
private Users user=new Users();
HttpServletRequest request;
private String errorMsg;
public String getErrorMsg() {
return errorMsg;
}
public void setErrorMsg(String errorMsg) {
this.errorMsg = errorMsg;
}
public Users getUser() {
return user;
}
public void setUser(Users user) {
this.user = user;
}
/**
*
* @������execute
* @����
* @return
* @throws Exception
* @�½����ڣ�Jun 29, 2010 2:41:42 PM
public String execute()throws Exception{
System.out.println("-----------"+user.getLoginName()+"----------------");
return "success";
}
*/
/**
*
* @������checkLogin
* @����
* @return
* @throws Exception
* @�½����ڣ�Jun 29, 2010 5:11:11 PM
*/
public String checkLogin(){
log.fatal("This is a fatal message.");
log.error("This is a fatal message.");
log.debug("This is a fatal message.");
IUserService iUserSer=new UserService();
if(iUserSer.checkLogin(user.getLoginName(), user.getLoginPwd())){
return "success";
}
request.setAttribute("errorMsg", "对不资1�7,您输入的用户名或密码不正硄1�7!");
return "fail";
}
public void setServletRequest(HttpServletRequest arg0) {
this.request=arg0;
}
public String saveUser(){
IUserService iUserSer=new UserService();
if(iUserSer.saveUser(user)){
request.setAttribute("regSuccess", "��ϲ�㣬ע��ɹ���");
return "fail";
}
request.setAttribute("regFail", "ע��ʧ�ܣ�");
return "reg";
}
}