开发者

url parameter set by label value in Spring MVC

开发者 https://www.devze.com 2023-04-10 19:10 出处:网络
Is there any way to make form url parameter submit by value of label? I mean, I want to do simple sear开发者_StackOverflow中文版ch form like this:

Is there any way to make form url parameter submit by value of label?

I mean, I want to do simple sear开发者_StackOverflow中文版ch form like this:

<form:form action="usersearch.do?searchName=....">
<input type="text" id="search" name="search"> <input type="submit" value="Search">
</form:form>

How to set url parameter "searchName" by value that was put in my form, like: usersearch.do?searchName=JohnSmith


If you change your form method to "GET" then the field names will be submitted on the query string. For example:

<form:form action="usersearch.do" method="GET">
    <input type="text" id="search" name="searchName"/>
    <input type="submit" value="Search"/>
</form:form>

Will do result in a GET on a URL that looks like:

.../usersearch.do?searchName={formValue} e.g. JohnSmith

0

精彩评论

暂无评论...
验证码 换一张
取 消