📄 changeuserinfo.java
字号:
package com.doone.fj1w.fjmgr.sysmgr;
import java.io.IOException;
import java.io.PrintWriter;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.doone.data.DacClient;
import com.doone.util.FileLogger;
import com.doone.uurm.Sys_Staff;
import com.doone.uurm.UserFactory;
/**
* Created by IntelliJ IDEA. User: lizhx Date: 2005-7-19 Time: 12:56:05
* Email:lizx@doone.com.cn
*/
public class ChangeUserInfo extends HttpServlet {
static final private String CONTENT_TYPE = "text/html; charset=GBK";
public void init() throws ServletException {
}
public void doGet(HttpServletRequest httpRequest,
HttpServletResponse httpResponse) throws ServletException,
IOException {
httpRequest.setCharacterEncoding("GBK");
httpResponse.setContentType(CONTENT_TYPE);
PrintWriter out = httpResponse.getWriter();
String sBirthDay = httpRequest.getParameter("BIRTHDAY").trim();
String sCartName = httpRequest.getParameter("CARTNAME").trim();
String sCartNo = httpRequest.getParameter("CARTNO").trim();
String sDuty = httpRequest.getParameter("DUTY").trim();
String sEducation = httpRequest.getParameter("EDUCATION").trim();
String sEMail = httpRequest.getParameter("EMAIL").trim();
String sFamilyAddress = httpRequest.getParameter("FAMILYADDRESS")
.trim();
String sFamilyTel = httpRequest.getParameter("FAMILYTEL").trim();
String sModileSid = httpRequest.getParameter("MODILESID").trim();
String sName = httpRequest.getParameter("NAME").trim();
String sPolitics = httpRequest.getParameter("POLITICS").trim();
String sPostalcode = httpRequest.getParameter("POSTALCODE").trim();
String sRelationTel = httpRequest.getParameter("RELATIONTEL").trim();
String sSex = httpRequest.getParameter("SEX").trim();
String sStaffCode = httpRequest.getParameter("STAFFCODE").trim();
SimpleDateFormat f1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
sBirthDay = Util.Replace(sBirthDay);
sCartName = Util.Replace(sCartName);
sCartNo = Util.Replace(sCartNo);
sDuty = Util.Replace(sDuty);
sEducation = Util.Replace(sEducation);
sEMail = Util.Replace(sEMail);
sFamilyAddress = Util.Replace(sFamilyAddress);
sFamilyTel = Util.Replace(sFamilyTel);
sModileSid = Util.Replace(sModileSid);
sName = Util.Replace(sName);
sPolitics = Util.Replace(sPolitics);
sPostalcode = Util.Replace(sPostalcode);
sRelationTel = Util.Replace(sRelationTel);
sSex = Util.Replace(sSex);
sStaffCode = Util.Replace(sStaffCode);
try {
Sys_Staff oSys_Staff = Sys_Staff.getInstance(new DacClient(),
sStaffCode);
try {
if (sBirthDay != null && !sBirthDay.equals(""))
oSys_Staff.setBirthDay(f1.parse(sBirthDay + " 00:00:00"));
} catch (ParseException e) {
FileLogger.getLogger().warn("设置生日时出错异常:", e);
}
oSys_Staff.setCartName(sCartName);
oSys_Staff.setCartNo(sCartNo);
oSys_Staff.setDuty(sDuty);
oSys_Staff.setEducation(sEducation);
oSys_Staff.setEMail(sEMail);
oSys_Staff.setFamilyAddress(sFamilyAddress);
oSys_Staff.setFamilyTel(sFamilyTel);
oSys_Staff.setModileSid(sModileSid);
oSys_Staff.setName(sName);
oSys_Staff.setPolitics(sPolitics);
oSys_Staff.setPostalcode(sPostalcode);
oSys_Staff.setRelationTel(sRelationTel);
oSys_Staff.setSex(sSex);
UserFactory.UserSetInfo(oSys_Staff);
// UserFactory.UserAdd(oSys_Staff);
out
.write("<script language=javascript>window.location.href='"+httpRequest.getContextPath()+"/view/sysmgr/OperSuccess.jsp';</script>");
} catch (RuntimeException e) {
out
.write("<script language=javascript>window.location.href='"+httpRequest.getContextPath()+"/view/sysmgr/OperFailure.jsp?error="
+ Util.Replace(e.getMessage()) + "';</script>");
}
}
public void doPost(HttpServletRequest httpRequest,
HttpServletResponse httpResponse) throws ServletException,
IOException {
doGet(httpRequest, httpResponse);
}
public static String replace(String source, String oldString,
String newString) {
StringBuffer output = new StringBuffer();
int lengthOfsource = source.length(); // 源字符串长度
int lengthOfold = oldString.length(); // 老字符串长度
int posStart = 0; // 开始搜索位置
int pos; // 搜索到的老字符串的位置
// source.indexOf(oldString,posStart)检索某子串在字符串postStart以后第一次出现的位置,如果未找到就返回一个-1。
while ((pos = source.indexOf(oldString, posStart)) >= 0) { // 得到字符串的位置(eg:如果有<br>就执行,没有就跳出,不要处理。)
// 将以posStart起始以pos-1结束之间的内容拷贝到另一个字符串中。因为posStar从0开始的。
output.append(source.substring(posStart, pos)); // append方法将文本添加到当前StringBuffer对象内容的结尾。
output.append(newString); // 替换成新字符串
posStart = pos + lengthOfold; // 位置也变为找到了之后的位置,pos为得到第一次出现字符的位置,lengthold为字符的长度
}
if (posStart < lengthOfsource) {
// source.substring(posStart)以lengthOfsource开始的字符串拷贝到列一个字符串中
output.append(source.substring(posStart));
}
// 这个方法将其内容转换成一个可以被用于输出的字符串对象。它允许操作对应的文本用于输出或数据存储。
return output.toString();
}
public static String Replace(String source) {
source = replace(source, "<", "<");
source = replace(source, ">", ">");
source = replace(source, "\t", " ");
source = replace(source, "\r\n", "\n");
source = replace(source, "\n", "<br>");
source = replace(source, " ", " ");
source = replace(source, "'", "'");
source = replace(source, "\\", "/");
source = replace(source, "\"", """);
return source.toString();
}
// Clean up resources
public void destroy() {
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -