📄 deluseraction.java
字号:
/**
* 删除注册用户的处理过程Action Bean
* DelUserAction
* @author usr
*/
package building;
import java.sql.*;
import javax.sql.*;
import javax.servlet.http.*;
import javax.servlet.ServletContext;
import org.apache.struts.action.*;
public final class DelUserAction extends Action
{
public ActionForward execute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception
{
DynaActionForm userIdForm = (DynaActionForm)form;
Integer userId = (Integer)userIdForm.get("userId");
ServletContext context = servlet.getServletContext();
DataSource dataSource = (DataSource)context.getAttribute(Constants.DATASOURCE_KEY);
DB db = new DB(dataSource);
//
HttpSession session = request.getSession();
Admin thisAdmin = (Admin)session.getAttribute(Constants.ADMIN_INFO_KEY);
//
String PageForward = null;
ActionMessages errors = new ActionMessages();
if ( thisAdmin.getLev() != 1 )
{
//此用户无权限查看所有管理员的资料
errors.add(ActionMessages.GLOBAL_MESSAGE,
new ActionMessage("errors.adminNoRight2ADD"));
if (!errors.isEmpty())
{
saveErrors(request,errors);
}//End of if
PageForward = "toWrong";
}//End of if
else
{
//此用户拥有权限查看所有管理员的资料
if ( Users.delUser(db,userId.intValue()) )
{
//删除成功
PageForward = "toDelUserOK";
}//End of if
else
{
//删除操作失败
errors.add(ActionMessages.GLOBAL_MESSAGE,
new ActionMessage("errors.delUserFail"));
if (!errors.isEmpty())
{
saveErrors(request,errors);
}//End of if
PageForward = "toWrong";
}//End of else
}//End of else
//Close database connection
db.close();
//Return the result
return(mapping.findForward(PageForward));
}//End of execute
}//End of class DelUserAction
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -