📄 editsaveaction.java
字号:
package to.view.Action;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import java.io.IOException;
import javax.servlet.ServletException;
import to.model.Right.RightBean;
import to.model.Right.RightItem;
import to.view.FormBean.UpdateRightFormBean;
public class EditSaveAction extends Action
{
/**
* This is the main action called from the Struts framework.
* @param mapping The ActionMapping used to select this instance.
* @param form The optional ActionForm bean for this request.
* @param request The HTTP Request we are processing.
* @param response The HTTP Response we are processing.
* @throws javax.servlet.ServletException
* @throws java.io.IOException
* @return
*/
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
request.setCharacterEncoding("gb2312");
UpdateRightFormBean urfb=(UpdateRightFormBean)form;
int RightID=Integer.parseInt(request.getParameter("RightID"));
String RightName=request.getParameter("RightName").trim();
String RightExplain=request.getParameter("RightExplain").trim();
RightBean rb=new RightBean();
RightItem ri=new RightItem();
ri.setRightID(RightID);
ri.setRightName(RightName);
ri.setRightExplain(RightExplain);
if(RightID==0)
{
request.setAttribute("question","权限编号不能为空!");
return mapping.findForward("failure");
}
if(RightName==null||RightName.length()<1)
{
request.setAttribute("question","权限名称不能为空!");
return mapping.findForward("failure");
}
else if(RightExplain==null||RightExplain.length()<1)
{
request.setAttribute("question","权限简介不能为空!");
return mapping.findForward("failure");
}
if(rb.updateRight(ri).equals("修改成功"))
{
return mapping.findForward("success");
}
request.setAttribute("question","修改失败");
return mapping.findForward("failure");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -