您现在的位置是:网站首页> 编程资料编程资料
jsp action中保存和修改的关系_JSP编程_
2023-05-25
123人已围观
简介 jsp action中保存和修改的关系_JSP编程_
Action中的代码片段
private String epid;//全局变量 得到的是一个以逗号分隔的字符串
public String getEpid() {
return epid;
}
public void setEpid(String epid) {
this.epid = epid;
}
public String edit() {
try {
if ("save".equals(save)) {//点击保存按钮的时候执行
return save();
} else {
loadInfo();
return RETURN_EDIT;
}
} catch (Exception e) {
super.printErrors(this.getRequest(), e, className);
return RETURN_ERROR;
}
}
private void loadInfo() throws Exception {
epid = this.getRequest().getParameter("id");//得到单个的epid
Long userid = getLoginUser().getUser().getUserID();
/**
功能:
得到单个对象 并把各个对象 放到VO对象中
页面中显示数据的值
**/
Ep ep = new Ep();
ep.setId(Long.parseLong(epid));
ep = epService.getEpById(ep);
epVO.setEp(ep);
// depart对象
Depart depart = new Depart();
depart.setDeptID(ep.getDeptid());
depart.setPlateNumber(ep.getName());
depart.setCreateBy(userid);
depart.setJudgeType(Integer.parseInt("0"));
String str[] = ep.getInfo().split(";");
String s1 = "";
for (int i = 0; i < str.length; i++) {
s1 = str[0];
}
if ("".equals(s1) || null == s1) {
depart.setRoute("暂无路线");
} else {
depart.setRoute(s1);
}
epVO.setDepart(depart);
// dept对象
Dept dept = new Dept();
dept = deptService.getDeptById(ep.getDeptid());
epVO.setDept(dept);
}
public String save() {
Long deptid = epVO.getDept().getDeptid();
try {
Depart depart = epVO.getDepart();
depart.setDeptID(deptid);
departService.insertDepart(depart);
super.printMsg(this.getRequest(), "保存成功!");
cleanObject();
} catch (Exception e) {
super.printErrors(this.getRequest(), e, className);
return RETURN_ERROR;
}
return list();
}
jap页面
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%@ taglib uri="/WEB-INF/web.tld" prefix="web"%>
相关内容
- jsp中一个页面引入另一个页面的实现代码_JSP编程_
- jsp base标签与meta标签学习小结_JSP编程_
- jsp项目中更改tomcat的默认index.jsp访问路径的方法_JSP编程_
- jsp中使用jstl导入html乱码问题解决方法_JSP编程_
- jsp中使用frameset框架 边框固定不让更改边框的大小_JSP编程_
- 图片路径中含有中文在jsp下不能正常显示的原因及解决_JSP编程_
- JSP常见的三个编译指令page、include、taglib_JSP编程_
- JSP中的编译指令和动作指令的两点区别_JSP编程_
- JSP中的include有几种形式?都有什么区别?_JSP编程_
- struts2+jquery实现ajax登陆实例详解_JSP编程_
