[JAVA] Informationen zum Erstellen von Apps mit Springboot

Ich erstelle gerade eine App mit den folgenden Funktionen. ・ Dateneingabe und Registrierung ・ Listenanzeige der registrierten Daten ・ Registrierungsdaten löschen ・ Mehrdeutige Suche nach registrierten Daten

Von den oben genannten ist die Fuzzy-Suche aufgrund eines Fehlers oder dergleichen noch nicht abgeschlossen.

Können Sie mir sagen, wo und wie ich das Problem beheben kann, damit der Fehler behoben wird und die Suchfunktion funktioniert? ◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆ Datenbank sp → Variable für die Eingabe von Touristenattraktionen (String-Typ)

◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆

Code //MyDataRepository.java

package com.example.demo;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;

import org.springframework.stereotype.Repository;

@Repository

public interface MyDataRepository extends JpaRepository<MyData, Integer> {

List<MyData> findBySpLike(String sp);

}

◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆

//MyController.java

package com.example.demo;

import java.util.List;

import java.util.Optional;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.stereotype.Controller;

import org.springframework.transaction.annotation.Transactional;

import org.springframework.web.bind.annotation.ModelAttribute;

import org.springframework.web.bind.annotation.PathVariable;

import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestMethod;

import org.springframework.web.bind.annotation.RequestParam;

import org.springframework.web.servlet.ModelAndView;

@Controller

public class MyController {

@Autowired

MyDataRepository repository;

//トップ

@RequestMapping("/")

public String index() {

	return "index";

}

//入力

@RequestMapping("/write")

public ModelAndView write(@ModelAttribute("formModel") MyData mydata,ModelAndView mv) {

	mv.setViewName("write");

	return mv;

}



@RequestMapping(value="/form", method=RequestMethod.POST)

@Transactional(readOnly=false)

public ModelAndView form(@ModelAttribute("formModel") MyData mydata, ModelAndView mv) {

	repository.saveAndFlush(mydata);

	return new ModelAndView("redirect:/");

}

//一覧

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

public ModelAndView list(ModelAndView mv) {

	mv.setViewName("list");

	List<MyData> list = repository.findAll();

	mv.addObject("datalist", list);

	return mv;

}

//詳細

@RequestMapping(value="/data/{id}",method=RequestMethod.GET)

public ModelAndView data(@ModelAttribute MyData mydata, @PathVariable int id, ModelAndView mv) {

	mv.setViewName("data");

	Optional<MyData> data = repository.findById(id);

	mv.addObject("formModel", data.get());

	return mv;

}

//削除

@RequestMapping(value="/delete/{id}",method=RequestMethod.GET)

public ModelAndView delete(@PathVariable int id, ModelAndView mv) {

	mv.setViewName("delete");

	Optional<MyData> data = repository.findById(id);

	mv.addObject("formModel", data.get());

	return mv;

}

@RequestMapping(value="/delete",method=RequestMethod.POST)

@Transactional(readOnly = false)

public ModelAndView remove(@RequestParam int id) {

	repository.deleteById(id);

	return new ModelAndView("redirect:/");

}

//検索

@RequestMapping(value="/search")

public ModelAndView search(@RequestParam("sp") String sp,ModelAndView mv) {

	List<MyData> list = repository.findBySpLike("%" + sp + "%");

	mv.setViewName("list");

	mv.addObject("dataList", list);

	return mv;

}

}

◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆

Top page </ title> </head> <body> <table> <tr> <th> <h2> Reise-App </ h2> </ th> </ tr> </table> <br> <input type = "button" value = "input" onclick = "location.href = '/ write'"> <br> <input type = "button" value = "list" onclick = "location.href = '/ list'"> <br> <input type = "button" value = "search" onclick = "location.href = '/ search'"> <br> </body> </html> <p>◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆◆</p> <p><--search.html--></p> <!DOCTYPE html> <html xmlns:th="http://www.thymeleaf.org" > <head> <meta charset="UTF-8"> <title> Suchbildschirm </ title> </head> <body> <form action="/search"> <p>Touristenziele usw .: <input type = "text" name = "sp" th: value = "* {tm}" /></p> <p><input type = "submit" value = "search" /> <a href="/list"> </a></p> <input type = "button" value = "search" onclick = "location.href = '/ list'"> </form> </body> </html> <!-- ENDDDDDDDDDDDDDDDDDDDDDDDDDDDDD --> <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <!-- ng_ads_new_ui --> <ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-6575041992772322" data-ad-slot="8191531813" data-ad-format="auto" data-full-width-responsive="true"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> <div style="margin-top: 30px;"> <div class="link-top" style="margin-top: 1px;"></div> <p> <font size="4">Recommended Posts</font> <!-- BEGIN LINK ************************* --> <div style="margin-top: 10px;"> <a href="/de/6488353db0f26edea132">Informationen zum Erstellen von Apps mit Springboot</a> </div> <div style="margin-top: 10px;"> <a href="/de/e9747531976b5329c4d4">Führen Sie in Java8 geschriebene Anwendungen in Java6 aus</a> </div> <div style="margin-top: 10px;"> <a href="/de/ff829561238440437b99">Vom Erstellen eines Spring Boot-Projekts bis zum Ausführen einer Anwendung mit VS Code</a> </div> <div style="margin-top: 10px;"> <a href="/de/c039ca4a42573a2eb962">Unterstützt Multi-Port mit SpringBoot</a> </div> <div style="margin-top: 10px;"> <a href="/de/d55d94c316d3c1acde7f">Ich habe eine Android-App erstellt, die mit HTTP abgerufen wird</a> </div> <div style="margin-top: 10px;"> <a href="/de/dd078d7d074bc8faf61b">[Rails] Erstellen Sie eine Anwendung</a> </div> <div style="margin-top: 10px;"> <a href="/de/23b771298f6ed45158e9">Ich habe einen Interpreter (Compiler?) Mit ungefähr 80 Zeilen in Ruby erstellt.</a> </div> <div style="margin-top: 10px;"> <a href="/de/242a92d06c9d9b28d914">Erste Schritte mit Java und Erstellen eines Ascii Doc-Editors mit JavaFX</a> </div> <div style="margin-top: 10px;"> <a href="/de/39d6b12f02f274cd4a08">Grobe Prozedur verbalisierte Ausgabe beim Erstellen einer App mit Rails</a> </div> <div style="margin-top: 10px;"> <a href="/de/5d269341ff1c4e4f50fd">Zusammenfassung der ersten Arbeiten beim Erstellen einer App mit Rails</a> </div> <div style="margin-top: 10px;"> <a href="/de/7dba25f4fa30ab0b1246">Verfahren zum Veröffentlichen einer Anwendung mit AWS (4) Erstellen einer Datenbank</a> </div> <div style="margin-top: 10px;"> <a href="/de/95cef8189a45e597f41c">So geben Sie db beim Erstellen einer App mit Rails an</a> </div> <div style="margin-top: 10px;"> <a href="/de/166f7aa8a69922e34d99">Über Java-Instanzen</a> </div> <div style="margin-top: 10px;"> <a href="/de/3552a51cf1d29a54c1f7">Ändern Sie den Port mit SpringBoot</a> </div> <div style="margin-top: 10px;"> <a href="/de/c0055e732460be3b8945">Mit Docker erstellte Webanwendung (1)</a> </div> <div style="margin-top: 10px;"> <a href="/de/cde66f1f81c9ddc4c2ea">Poste ein Bild mit POSTMAN</a> </div> <div style="margin-top: 10px;"> <a href="/de/dffba03df3c201d5d053">Hallo Welt mit SpringBoot / Gradle</a> </div> <div style="margin-top: 10px;"> <a href="/de/9de7baf4748b95f06e8b">Fügen Sie @GeneratedValue nicht unnötig hinzu, wenn Sie eine Entität mit JPA erstellen</a> </div> <div style="margin-top: 10px;"> <a href="/de/a245edec975c596534fd">Ich habe versucht, eine Android-Anwendung mit MVC zu erstellen (Java)</a> </div> <div style="margin-top: 10px;"> <a href="/de/ba13d78aefe821600357"># 1 [Anfänger] Erstellen Sie eine Webanwendung (Website) mit Eclipse aus Wissen 0. "Lassen Sie uns eine Umgebung zum Erstellen von Web-Apps erstellen"</a> </div> <!-- END LINK ************************* --> </p> </div> </div> </div> <div class="footer text-center" style="margin-top: 40px;"> <!-- <p> Licensed under cc by-sa 3.0 with attribution required. </p> --> </div> <script src="https://cdn.jsdelivr.net/npm/jquery@3.4.1/dist/jquery.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.3.1/dist/js/bootstrap.min.js"></script> <script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@10.1.2/build/highlight.min.js"></script> <!-- ads --> <script data-ad-client="ca-pub-6575041992772322" async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <!-- end ads --> </body> </html>