加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 资源网站 > 资源 > 正文

html – 在Thymeleaf中创建下拉菜单和表单

发布时间:2020-12-14 21:17:34 所属栏目:资源 来源:网络整理
导读:我想创建一个下拉菜单,允许客户端按下拉菜单中指定的字段搜索用户.例如,按州搜索,按城市搜索等. 这是我到目前为止: pSearch options:/p form action="#" th:action="@{/get/{value}" method="get" select option th:value="AllUsers"Search all users/optio
我想创建一个下拉菜单,允许客户端按下拉菜单中指定的字段搜索用户.例如,按州搜索,按城市搜索等.

这是我到目前为止:

<p>Search options:</p>
    <form action="#" th:action="@{/get/{value}" method="get">
    <select>
        <option th:value="AllUsers">Search all users</option>
        <option th:value="ByUsername">Search by user name</option>
        <option th:value="ByFirstname">Search by first name</option>
        <option th:value="ByLastname">Search by last name</option>
        <option th:value="ByAddress">Search by address</option>
        <option th:value="ByCity">Search by city</option>
        <option th:value="ByState">Search by state</option>
        <option th:value="ByZipCode">Search by zip code</option>
        <option th:value="ByPhoneNumber">Search by phone number</option>
        <option th:value="ByEmail">Search by email</option>
    </select>
    <input type="text" th:field="value" name="searchField" />
    <input type="submit" value="Search" name="searchButton" />
    </form>

我只是不确定如何连接下拉列表中当前所选项的操作和值标记来指定URI.如果用户选择,并且他输入“Maryland”,我该如何指定相应的URI标签?

这将是我在Spring中执行操作的方法:

@RequestMapping(value = "/get/ByState",method = RequestMethod.GET)
public String getByState() {
         .....
}

@RequestMapping(value = "/get/ByCity",method = RequestMethod.GET)
public String getByCity() {
         .....
}

解决方法

您在此链接中只有所需的答案:

http://fruzenshtein.com/spring-mvc-form-select-tag/

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读