Hello guys i am new in spring boot and want to make a function in which i enter a number in my search box and the table related to the data displays on the web page .
and then info should be visible . considered me as a noob in spring boot and want to do this function plz help i am using html and css for front end. please provide a suitable example for the same i am using controller class and this is my controller class
package com.complaintportal.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import com.complaintportal.entities.tbl_voicechat;
import com.complaintportal.serv.tbl_voicechatservice;
@org.springframework.stereotype.Controller
public class Controller {
/*
* @Autowired
*
* private tbl_voicechatservice voiceservice;
*/
@RequestMapping("/home")
public String home(Model model) {
model.addAttribute("title", "Welcome to Complaint Portal");
return "home";
}
@RequestMapping("/complaint")
public String complaint(Model model) {
model.addAttribute("title", "Complaint lodge");
return "complaint";
}
@RequestMapping("/minutes")
public String minutes(Model model) {
model.addAttribute("title", "Minutes not updated");
return "minutes";
}
@RequestMapping("/unvoicht")
public String unablevoicechat(Model model) {
model.addAttribute("title", "Complaint lodge");
return "unvoicht";
}
@GetMapping("/login")
public String login() {
return "/login";
}
/*
* @RequestMapping(value = "/user/{ani}", method = RequestMethod.GET) public
* tbl_voicechat getDataByANI(@PathVariable("ani") String ani) { return
* voiceservice.getDataByANI(ani); }
*/
}
Please help and provide suitable example
@RequestMapping(value = "/user", method = RequestMethod.GET) public tbl_voicechat getDataByANI(@RequestParam(name = "ani") String ani) {
returnvoiceservice.getDataByANI(ani);
}
Your code should work but try using this.
If it does not work share your HTML also.