基本上我在 SpringBoot 上開發了微服務,它從 excel 表單中獲取資料并將其顯示為表格。我想出了如何做到這一點,它作業正常。
現在我使用彈性搜索,當我自己發送請求時效果很好。現在我需要這個來處理 thymeleaf html。
基本上我的頁面現在看起來像這樣

我需要的是,我將搜索輸入到搜索欄中,當我按下“提交”按鈕時,它從搜索欄中獲取 searchRequest,使用用戶之前輸入的引數重定向到另一個鏈接。這是我的 html 代碼
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>Freight Masters LLC Agents</title>
<style>
/*** COLORS ***/
/*** DEMO ***/
html,
body {
height: 100%;
margin: 0;
}
body {
background: #F4B942;
font: 13px monospace;
color: #232e57;
}
p {
margin-top: 30px;
}
.cntr {
display: table;
width: 100%;
height: 100%;
}
.cntr .cntr-innr {
display: table-cell;
text-align: center;
vertical-align: middle;
}
/*** STYLES ***/
.search {
display: inline-block;
position: relative;
height: 35px;
width: 35px;
box-sizing: border-box;
margin: 0px 8px 7px 0px;
padding: 7px 9px 0px 9px;
border: 3px solid #232e57;
border-radius: 25px;
transition: all 300ms ease;
cursor: text;
}
.search:after {
content: "";
position: absolute;
width: 3px;
height: 20px;
right: -5px;
top: 21px;
background: #232e57;
border-radius: 3px;
transform: rotate(-45deg);
transition: all 300ms ease;
}
.search.active,
.search:hover {
width: 300px;
margin-right: 0px;
}
.search.active:after,
.search:hover:after {
height: 0px;
}
.search input {
width: 100%;
border: none;
box-sizing: border-box;
font-family: Helvetica;
font-size: 15px;
color: inherit;
background: transparent;
outline-width: 0px;
}
.button {
width: 180px;
height: 45px;
font-family: 'Roboto', sans-serif;
font-size: 11px;
text-transform: uppercase;
letter-spacing: 2.5px;
font-weight: 500;
color: #000;
background-color: #fff;
border: none;
border-radius: 45px;
box-shadow: 0px 8px 15px rgba(0, 0, 0, 0.1);
transition: all 0.3s ease 0s;
cursor: pointer;
outline: none;
}
.button:hover {
background-color: #232e57;
box-shadow: 0px 15px 20px #0f152b66;
color: #fff;
transform: translateY(-7px);
}
</style>
</head>
<body>
<div class="cntr">
<div class="cntr-innr">
<label style="margin-bottom: 32px" class="search" for="inpt_search">
<input th:name="searchParams" id="inpt_search" type="text"/>
</label><br>
<button class="button">Submit</button>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.6.1.min.js" integrity="sha256-o88AwQnZB VDvE9tvIXrMQaPlFFSUTR nldQm1LuPXQ=" crossorigin="anonymous"></script>
<script>
$("#inpt_search").on('focus', function () {
$(this).parent('label').addClass('active');
});
$("#inpt_search").on('blur', function () {
if($(this).val().length == 0)
$(this).parent('label').removeClass('active');
});
</script>
</body>
</html>
提前致謝。
uj5u.com熱心網友回復:
您可能會使用類似以下的內容。順便說一句,我建議將其包裝到一個<form>元素中。
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>Freight Masters LLC Agents</title>
<style>
/*** COLORS ***/
/*** DEMO ***/
html,
body {
height: 100%;
margin: 0;
}
body {
background: #F4B942;
font: 13px monospace;
color: #232e57;
}
p {
margin-top: 30px;
}
.cntr {
display: table;
width: 100%;
height: 100%;
}
.cntr .cntr-innr {
display: table-cell;
text-align: center;
vertical-align: middle;
}
/*** STYLES ***/
.search {
display: inline-block;
position: relative;
height: 35px;
width: 35px;
box-sizing: border-box;
margin: 0px 8px 7px 0px;
padding: 7px 9px 0px 9px;
border: 3px solid #232e57;
border-radius: 25px;
transition: all 300ms ease;
cursor: text;
}
.search:after {
content: "";
position: absolute;
width: 3px;
height: 20px;
right: -5px;
top: 21px;
background: #232e57;
border-radius: 3px;
transform: rotate(-45deg);
transition: all 300ms ease;
}
.search.active,
.search:hover {
width: 300px;
margin-right: 0px;
}
.search.active:after,
.search:hover:after {
height: 0px;
}
.search input {
width: 100%;
border: none;
box-sizing: border-box;
font-family: Helvetica;
font-size: 15px;
color: inherit;
background: transparent;
outline-width: 0px;
}
.button {
width: 180px;
height: 45px;
font-family: 'Roboto', sans-serif;
font-size: 11px;
text-transform: uppercase;
letter-spacing: 2.5px;
font-weight: 500;
color: #000;
background-color: #fff;
border: none;
border-radius: 45px;
box-shadow: 0px 8px 15px rgba(0, 0, 0, 0.1);
transition: all 0.3s ease 0s;
cursor: pointer;
outline: none;
}
.button:hover {
background-color: #232e57;
box-shadow: 0px 15px 20px #0f152b66;
color: #fff;
transform: translateY(-7px);
}
</style>
</head>
<body>
<div class="cntr">
<div class="cntr-innr">
<label style="margin-bottom: 32px" class="search" for="inpt_search">
<input th:name="searchParams" id="inpt_search" type="text"/>
</label><br>
<button class="button submit_search">Submit</button>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.6.1.min.js" integrity="sha256-o88AwQnZB VDvE9tvIXrMQaPlFFSUTR nldQm1LuPXQ=" crossorigin="anonymous"></script>
<script>
$("#inpt_search").on('focus', function () {
$(this).parent('label').addClass('active');
});
$("#inpt_search").on('blur', function () {
if($(this).val().length == 0)
$(this).parent('label').removeClass('active');
});
/// On submit
$(".submit_search").on('click', function () {
var searchString = $("#inpt_search").val();
/// Use searchString
/// (example)
window.open("https://www.example.com/?query=" searchString);
});
</script>
</body>
</html>
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/534307.html
上一篇:在測驗用例運行中禁用SQS偵聽器
下一篇:我在springboot應用程式中的測驗用例是從主application.yaml檔案而不是application-test.yaml中讀取的
