formSubmit(url,sTarget);的使用

一、formSubmit函数代码

function formSubmit(url, sTarget) {
//        alert(1)
        document.forms[0].target = sTarget
        document.forms[0].action = url;
        document.forms[0].submit();
        return true;
    }

url是要请求的路径,sTarget是源路径

二、实例:

点击导出按钮后即触发formSubmit(‘exportUserExcelPlus’,’_self’)函数,

<button class="btn btn-info " type="button" id="export" onclick="formSubmit('exportUserExcelPlus','_self');this.blur();"><i class="fa fa-cloud-download"></i>导出</button>

_self代表当前页面所处路径,exportUserExcelPlus即要请求的路径,注意,它会自动在源路径的基础上拼接要请求的路径。

源路径为 :http://localhost:8081/user/userManage

这里写图片描述

点击导出按钮后:http://localhost:8081/user/exportUserExcelPlus

这里写图片描述

三、需要注意的:

jsp页面上是否有form标签只会影响有无参数的传递,并不影响能否请求指定路径,并不影响对指定路径的请求。

没加form标签前:(请求为post类型)

这里写图片描述

加了form标签后:(请求为get类型,且有参数的传递)

这里写图片描述

四、写在最后:

Knowing your goals will increase your motivation.Once you konw where you want to go,start breaking your long-term goals down to manageable daily actions that are process-focused.Settting daily action-packed goals will help you stay focused on what you can do to ensure your long-term results come true~~~

posted @ 2017-12-04 21:24  晓风残月龙  阅读(302)  评论(0编辑  收藏  举报