thymeleaf ajax请求,jquery - Thymeleaf, Ajax, Springboot - Stack Overflow

I try to use ajax with Thymeleaf, however I have faced some problems and I haven't solve it yet.

My operation is try to send a parameter to controller than calculate it and display in same page into a label.

My HTML code is

window.onload = function () {

document.getElementsByName("Thing")[0].addEventListener('change', doThing);

function doThing(evt) {

var url = [[@{/

calculation

}

]]

;

$("#fill").load(url + '?input=' + evt.target.value);

}

}

In the html code, I use ajax and redirect it to controller with var url = [[@{/calculation} ]].

My controller.

@RequestMapping(value = "/calculation", method = RequestMethod.GET)

@ResponseBody

public int multiply(@RequestParam int input, Model model) {

return input;

}

With these operation I can calculate input and send it to my html. Than with ajax function, I capture it and send to . After that, I see my success result on the page.

My problem is that, I want to send the input from controller to

And For it I need to change my controller of course like that.

@RequestMapping(value = "/calculation", method = RequestMethod.GET)

@ResponseBody

public String multiply(@RequestParam int input, Model model) {

model.addAttribute("amount",input);

return "test";

}

}

However, I couldn't write my input value to label with using of thmeleaf.

The problem is when I do first operation, there is no problem, but if i want to assing the input value to a label or an input text, my operation is not working.

Could you help me please.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值