'How to use json in spring boot and html
I am new to spring boot. how can I show the json list result from controller to html?
my controller code
public class FormJsonController {
@Autowired
private UserService userService;
@Autowired
private FsnroMasterService fsnrmstservice;
List<FsnroMasterBean> fsnroOMCMstList;
List<FsnroMasterBean> fsnroOMCMstList1;
@RequestMapping("/popOMC")
public List fsrOsmMstAction() {
System.out.println("Start");
fsnroOMCMstList1 = new ArrayList<FsnroMasterBean>();
fsnroOMCMstList1 = fsnrmstservice.GetOmsMaster();
System.out.println(fsnroOMCMstList1.size());
return fsnroOMCMstList1 ;
}
}
from above code i am getting fsnroOMCMstList1 successfully. how do i use this list to html page?
var tdn;
$.getJSON('popOMC',{async:true}, function(jsonResponse) {
alert("Mohan");
tdn='<option value=0>Select Uom</option>';
$.each(jsonResponse.fsnroOMCMstList1, function(listkey,listvalue) {
tdn=tdn+'<option value='+listkey+'>'+listvalue+'</option>';
});
alert(tdn);
});
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
