📄 modifyuseraction.java
字号:
package com.stsc.archive.manage;
import javax.servlet.http.*;
import org.apache.struts.action.*;
import java.util.Properties;
import com.stsc.util.STPoolDataSet;
import com.stsc.util.STResultSet;
import org.apache.struts.util.MessageResources;
/*
The action for the creation of a book.
@author stephan@stephanwiesner.de
*/
public final class ModifyUserAction extends Action
{
/**
@param mapping The ActionMapping used to select this instance
@param form The optional ActionForm bean for this request (if any)
@param req The non-HTTP request we are processing
@param res The non-HTTP response we are creating
@return Return an ActionForward instance describing where and how
control should be forwarded, or null if the response has already
been completed.
*/
public ActionForward perform(ActionMapping mapping,
ActionForm form, HttpServletRequest req,
HttpServletResponse res)
{
System.out.println("Start perform(" + form + ") . . ." );
String userName = req.getParameter("userName");
String depart = req.getParameter("depart");
String enterName = req.getParameter("enterName");
String rowsPerPage = req.getParameter("rowsPerPage");
/* try
{
userName = new String(userName.getBytes("ISO-8859-1"),"gb2312");
depart = new String(depart.getBytes("ISO-8859-1"),"gb2312");
enterName = new String(enterName.getBytes("ISO-8859-1"),"gb2312");
}
catch(Exception e)
{
System.out.println("encoding error.");
}*/
System.out.println(userName);
System.out.println(depart);
System.out.println(enterName);
if(userName.length() < 1)
{
ActionErrors errors = new ActionErrors();
errors.add("nameLength", new ActionError("error.addUser.nameLength"));
System.out.println("nameLength error.");
saveErrors(req, errors);
return (new ActionForward(mapping.getInput()));
}
else
{
Properties dbBase = new Properties();
dbBase.setProperty("dsJndiName", Constants.ARCHIVE_DBSOURCE_KEY);
int iRows = 0;
try
{
iRows = Integer.parseInt(rowsPerPage);
}catch(NumberFormatException e)
{
System.out.println("数字转换出现异常:可能包含有小数点");
iRows = 0;
}
if(iRows < 1)
{
iRows = 10;
}
if(depart == null)
depart = "";
STPoolDataSet data = new STPoolDataSet();
String sql = "UPDATE fUserName SET UserName='" + userName + "', Department='" + depart + "', RowsPerPage=" + iRows + " WHERE EnterName='" + enterName + "'";
boolean bRet = data.executeSQL(sql, dbBase);
CommonSql comsql = new CommonSql();
comsql.ToUserManager(form, req);
/** //---------------------------------------
sql = "SELECT * FROM fUserName ORDER BY EnterName";
STResultSet rs = data.getSTResult(sql, dbBase);
UserList userList = new UserList();
while(rs!=null && rs.next())
{
User user = new User();
user.setEnterName(rs.getString("EnterName"));
user.setUserName(rs.getString("UserName"));
user.setDepartment(rs.getString("Department"));
userList.addUser(user);
}
// Save our logged-in user in the session
HttpSession session = req.getSession();
session.setAttribute(Constants.USER_MANAGE_KEY, userList);
*/ //========================================
return mapping.findForward("userManage");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -