?? addblockadmindo.java
字號:
package com.lovo.servlet;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import com.lovo.factory.BOFactory;
import com.lovo.po.AreaPO;
import com.lovo.po.BlockPO;
import com.lovo.po.UserPO;
public class AddBlockAdminDO extends HttpServlet {
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
this.doPost(request, response);
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.setCharacterEncoding("utf-8");
response.setContentType("text/html;charset=utf-8");
response.setCharacterEncoding("utf-8");
HttpSession session = request.getSession(true);
String blockAdmin = request.getParameter("blockAdmin");
String blockIdStr = request.getParameter("blockId");
int blockId = 0;
if(blockIdStr.matches("\\d+")) {
blockId = Integer.parseInt(blockIdStr);
}
boolean isSetUpSuc = false;
String[] blockAdmins = blockAdmin.split(",");
for(int i=0; i<blockAdmins.length; i++) {
UserPO user = BOFactory.getUserBOInstance().queryByName(blockAdmins[i]);
BlockPO block = BOFactory.getBlockBOInstance().queryBlockById(blockId);
user.setBlock(block);
isSetUpSuc = BOFactory.getUserBOInstance().addBlockAdmin(user);
if(isSetUpSuc) {
continue;
} else {
session.setAttribute("errorInfo", "添加版主主失敗");
response.sendRedirect("../web/error.jsp");
return;
}
}
response.sendRedirect("../web/admin/setUpSuc.jsp");
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -