xml
<!--搜索 '%?%'-->
<select id="searchbox" resultType="com.my.domain.testpojo">
SELECT * FROM time WHERE (title LIKE '%?%') OR (sub_title LIKE '%?%')
</select>
mapper
//搜索 ,@Param("sub_title")String sub_title
public List<testpojo> searchbox(@Param("title")String title);
Service
public List<testpojo> searchbox(String title) {
List<testpojo> time3 = apiMapper.searchbox(title);
System.out.println("123456"+time3);
System.out.println("852"+time3);
return time3;
}
controller
@RequestMapping(value = "/searchbox",method =RequestMethod.POST )
public List<testpojo> searchbox(HttpServletRequest request, HttpServletResponse response) {
response.setContentType("text/html;charset=utf-8");
/* 設定回應頭允許ajax跨域訪問 */
response.setHeader("Access-Control-Allow-Origin", "*");
/* 星號表示所有的異域請求都可以接受, */
response.setHeader("Access-Control-Allow-Methods", "GET,POST");
String formData = request.getParameter("formData");
List<testpojo> time3= apiService.searchbox(formData);
System.out.println("搜索====="+time3);
return time3;
}
這是前端小程式的
wx.request({
url: 'http://localhost:8089/api/searchbox' ,
data:{
formData:formData
},
method: "POST",
header: { 'content-type': 'application/x-www-form-urlencoded"' },
success: function (res) {
console.log(res.data)
that.setData({
re: res.data,
})
wx.showToast({
title: '已提交',
icon: 'success',
duration: 2000
})
}
})
123456[]
852[]
搜索=====[]
取不到值,是哪里錯了,求大神幫指點
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/227194.html
標籤:Java相關
