为什么前端传的值后端获取不到,大神帮看看
心大自然宽 2020-11-24 11:03:11 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[]
搜索=====[]
取不到值,是哪里错了,求大神帮指点