html - 从数据库中搜索并使用spring boot + html将其显示在网页中
问题描述
大家好,我是 Spring Boot 的新手,想创建一个功能,在我的搜索框中输入一个数字,并在网页上显示与数据相关的表格。
然后信息应该是可见的。认为我是 Spring Boot 中的菜鸟,并且想要做这个功能请帮助我使用 html css for fromt end。请为我使用控制器类提供一个合适的示例,这是我的控制器类
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); }
*/
}
请帮助并提供合适的例子
解决方案
@RequestMapping(value = "/user", method = RequestMethod.GET) public tbl_voicechat getDataByANI(@RequestParam(name = "ani") String ani) {
returnvoiceservice.getDataByANI(ani);
}
您的代码应该可以工作,但请尝试使用它。
如果它不起作用,也分享您的 HTML。
推荐阅读
- r - 为什么多列在R中显示为一个向量
- java - json模式中的空对象验证
- python - 如何使用 pandas 查找大学排名和全球排名?
- lucene - lucene java11警告?
- javascript - 用于在 HTML 上为 Web 应用程序实现 PowerPoint 查看器的选项(使用提供的 i-frame 标签嵌入除外)
- c# - BLOB 触发的 Azure 函数中的可选变量
- javascript - 输入字段的React Bootstrap表单样式
- swift - 如何使用协议来表达这个`map`函数
- html - 关闭编译器未检测到脚本标签内的 json
- python - 熊猫中的多级标题问题