The relationship between saving and modifying in JSP action

Time:2020-12-1

Code fragment in action

Copy codeThe code is as follows:
Private string EPID; / / the global variable gets a comma separated string
public String getEpid() {
        return epid;
}

public void setEpid(String epid) {
        this.epid = epid;
}

public String edit() {
        try {
If (“save”. Equals (save)) {/ / click the Save button
                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”); / / get a single EPID
        Long userid = getLoginUser().getUser().getUserID();
        /**
Function:
Get a single object and put each object in the VO object
The value of the data displayed in the page

        **/

        Ep ep = new Ep();
        ep.setId(Long.parseLong(epid));
        ep = epService.getEpById(ep);
        epVO.setEp(ep);
/ / Department object
        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 (no route for the time being);
        } else {
            depart.setRoute(s1);
        }
        epVO.setDepart(depart);
/ / dept object
        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 (), “saved successfully!”);

            cleanObject();
        } catch (Exception e) {
            super.printErrors(this.getRequest(), e, className);
            return RETURN_ERROR;
        }

        return list();
    }

Jap page

Copy codeThe code is as follows:
<%@ 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”%>
<!DOCTYPE html PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN” “http://www.w3.org/TR/html4/loose.dtd”>
<html>
    <head>
        <meta http-equiv=”Content-Type” content=”text/html; charset=UTF-8″>
< title > Modify payment information
        <web:jquery validate=”true” formId=”tableform” />
        <link type=”text/css” rel=”stylesheet” href=”styles/css.css”>
        <script language=”javascript” type=”text/javascript” src=”scripts/DatePicker/WdatePicker.js”></script>
        <script language=”javascript” type=”text/javascript” src=”scripts/Globals.js”></script>
    </head>
    <body>
        <form action=”” method=”POST” name=”tableform”>
        <web:error />
        < web:tableTitle name= “Modify payment information”
        <s:hidden name=” epVO.dept.deptid “/ > / / hide the value passed in
        <s:hidden name=”epVO.depart.createBy”  />
        <s:hidden name=”id” />
        <div>
            <table width=”100%” border=”0″ cellspacing=”0″ cellpadding=”0″>

            </table>
        </div>
        <div>
< input type = “submit” value = save “style =” display: None “/ >
< a http: / / ාා “onclick =” save() “> save</a>
        </div>
        </form>
    </body>
</html>

<script language=”JavaScript” type=”text/JavaScript”>
/ / save
    function save() {
        var obj = document.getElementById(“tableform”);
        obj.action = ‘<s:property value=”#request.saveUrl”/>’;
        var submitbtn = document.getElementById(“submitbtn”);
        submitbtn.click (); / / submit events through JS time control
    }
/ / display
    function query(){
        window.location.href='<s:url value=”/listEp.action”/>’;
    }
/ / load date control
    $(document).ready(function(){
        addFormValidator();
        $(“#sendTime”).attr(“readonly”,”readonly”);
        $(“#sendTime”).click(function(){WdatePicker({isShowClear:false,dateFmt:’yyyy-MM-dd HH:mm:ss’});});
    });

</script>

Recommended Today

Vue project to achieve image upload function

This example for you to share the Vue image upload function of the specific code, for your reference, the specific content is as follows <!DOCTYPE html> <html lang=”en”> <head> <meta charset=”UTF-8″> <title>Title</title> </head> <style> .uploadimg{ width:100px; height:100px; border-radius: 50%; } </style> <body> <div> <input type=”file” @change=”upTx”> <img :src=”imgsrc”/> </div> </div> </body> <!–<script src=”util.js”>–> <!–</script>–> <script […]