@Select模糊查询待解决

master
istars 7 years ago
parent 3935b66432
commit 9917b19811

@ -7,7 +7,7 @@ import java.util.List;
@Mapper @Mapper
public interface productMapper { public interface productMapper {
@Select("select * from product where productName like '%#{productName}%'") @Select("select * from product where productName like '%${productName}%'")
public List<Product> findByNameLike(String productName); public List<Product> findByNameLike(String productName);
@Select("select * from product where productName = #{category}") @Select("select * from product where productName = #{category}")

@ -21,7 +21,7 @@ import java.util.List;
//@Controller //@Controller
@RestController @RestController
@RequestMapping("/search") @RequestMapping("/")
public class SearchServiceController{ public class SearchServiceController{
@Autowired @Autowired
private ProductSearchService productSearchService; private ProductSearchService productSearchService;

@ -1,6 +1,6 @@
$(function(){ $(function(){
$.ajax({ $.ajax({
url: "/search", url: "/search/show",
type: "post", type: "post",
data: {}, data: {},
dataType: "json", dataType: "json",

@ -1,46 +1,21 @@
//以下代码为AJAX提交搜索请求代码,实际应用中请启用以下代码,并正确填写搜索提交路径和数据获取路径. //以下代码为AJAX提交搜索请求代码,实际应用中请启用以下代码,并正确填写搜索提交路径和数据获取路径.
//$('#btn').click(function() {
// $.ajax({
// cache: true, //保留缓存数据
// type: "POST", //为post请求
// url: "url", //提交到指定路径
// async: true, //true可异步false不可异步
// data: $("#serch").val(), //提交数据为input里value
// async: true, //true可异步false不可异步
// error: function(request) { //请求失败之后的操作
// return;
// alert("提交失败");
// },
// success: function(data) { //请求成功之后的操作
// $.ajax({
// cache: true, //保留缓存数据
// type: "GET", //为get请求
// url: "url", //数据返回接口路径
// async: true, //true可异步false不可异步
// error: function(request) { //请求失败之后的操作
// return;
// alert("请求失败");
// },
// success: function(data) { //请求成功之后的操作
// var x = '';
// $.each(data, function(index, value) {
// var trs = "";
// trs += "<label class='el-checkbox'><img src=" + data[index].head_img + "alt='' /><h4>" + data[index].nickname + "</h4><p>" + data[index].desc + "</p><input name='public' type='checkbox' value='' /></label>";
// x += trs;
// });
// $(".content").html(x);
// }
// });
// }
// });
//})
//以下代码为本次测试数据的打印,实际应用中请把以下代码全部注释,并启用上面的代码块.
$('#btn').click(function() { $('#btn').click(function() {
$.ajax({
cache: true, //保留缓存数据
type: "POST", //为post请求
url: "/search/sh", //提交到指定路径
async: true, //true可异步false不可异步
data: $("#serch").val(), //提交数据为input里value
async: true, //true可异步false不可异步
error: function(request) { //请求失败之后的操作
return;
alert("提交失败");
},
success: function(data) { //请求成功之后的操作
$.ajax({ $.ajax({
cache: true, //保留缓存数据 cache: true, //保留缓存数据
type: "GET", //为get请求 type: "GET", //为get请求
url: "http://www.17sucai.com/preview/575598/2018-05-09/%E5%85%AC%E4%BC%97%E5%8F%B7/js/shuju.json", //获取数据接口指定路径 url: "url", //数据返回接口路径
async: true, //true可异步false不可异步 async: true, //true可异步false不可异步
error: function(request) { //请求失败之后的操作 error: function(request) { //请求失败之后的操作
return; return;
@ -49,16 +24,41 @@ $('#btn').click(function() {
success: function(data) { //请求成功之后的操作 success: function(data) { //请求成功之后的操作
var x = ''; var x = '';
$.each(data, function(index, value) { $.each(data, function(index, value) {
console.log(data[index].wxid + '' + data[index].nickname + '' + data[index].head_img + '' + data[index].desc);
var trs = ""; var trs = "";
trs += "<label class='el-checkbox'><img src=" + data[index].head_img + "alt='' /><h4>" + data[index].nickname + "</h4><p>" + data[index].desc + "</p><input name='public' type='radio' value='' /></label>"; trs += "<label class='el-checkbox'><img src=" + data[index].head_img + "alt='' /><h4>" + data[index].nickname + "</h4><p>" + data[index].desc + "</p><input name='public' type='checkbox' value='' /></label>";
x += trs; x += trs;
}); });
$(".content").html(x); $(".content").html(x);
} }
}); });
}
});
}) })
//以下代码为本次测试数据的打印,实际应用中请把以下代码全部注释,并启用上面的代码块.
// $('#btn').click(function() {
// $.ajax({
// cache: true, //保留缓存数据
// type: "GET", //为get请求
// url: "http://www.17sucai.com/preview/575598/2018-05-09/%E5%85%AC%E4%BC%97%E5%8F%B7/js/shuju.json", //获取数据接口指定路径
// async: true, //true可异步false不可异步
// error: function(request) { //请求失败之后的操作
// return;
// alert("请求失败");
// },
// success: function(data) { //请求成功之后的操作
// var x = '';
// $.each(data, function(index, value) {
// console.log(data[index].wxid + '' + data[index].nickname + '' + data[index].head_img + '' + data[index].desc);
// var trs = "";
// trs += "<label class='el-checkbox'><img src=" + data[index].head_img + "alt='' /><h4>" + data[index].nickname + "</h4><p>" + data[index].desc + "</p><input name='public' type='radio' value='' /></label>";
// x += trs;
// });
// $(".content").html(x);
// }
// });
// })
//点击确认,提交所选公众号名称,修改提交地址 //点击确认,提交所选公众号名称,修改提交地址
$('#btn2').click(function(){ $('#btn2').click(function(){
var radioValue = $("input[type='radio']:checked").parent().find('h4').html(); var radioValue = $("input[type='radio']:checked").parent().find('h4').html();

@ -34,7 +34,7 @@
<img src="images/show.png"> <img src="images/show.png">
</div> </div>
<div class="aui-flex-box"> <div class="aui-flex-box">
<h2>用户 <em>XXX</em></h2> <h2><em>李**</em></h2>
</div> </div>
<div class="aui-pri-button"> </div> <div class="aui-pri-button"> </div>
</div> </div>
@ -50,7 +50,7 @@
</div> </div>
<div class="aui-text-time"> </div> <div class="aui-text-time"> </div>
<div class="aui-button-get"> <div class="aui-button-get">
<button id="apply", onclick="location='apply.html'">申请</button> <button id="apply", onclick="location='loanInformation.html'">申请</button>
</div> </div>
</div> </div>
<div class="aui-dotted"> </div> <div class="aui-dotted"> </div>

@ -9,15 +9,17 @@
</head> </head>
<body> <body>
<form action="/search" method="post">
<div class="headBox"> <div class="headBox">
<h2 class="titHead">产品搜索</h2> <h2 class="titHead">产品搜索</h2>
<!--<h3 class="titNeck">内容简介</h3>--> <!--<h3 class="titNeck">内容简介</h3>-->
<form action="/search/show" method="post">
<div class="search"> <div class="search">
<input name="productName" type="text" placeholder="搜索"> <input name="productName" type="text" placeholder="搜索">
<button name="btn" type="button"></button> <button name="btn" type="button"></button>
</div> </div>
</form>
</div> </div>
<div class="content"> <div class="content">
@ -26,7 +28,7 @@
<input type="submit" name="action" id="btn2" value="确&nbsp;&nbsp;定" /> <input type="submit" name="action" id="btn2" value="确&nbsp;&nbsp;定" />
</div> </div>
</form>
<script type="text/javascript" src="js/search.js"></script> <script type="text/javascript" src="js/search.js"></script>
</body> </body>

Loading…
Cancel
Save