-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
44 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
src/main/java/de/holarse/web/controller/SearchController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package de.holarse.web.controller; | ||
|
||
import de.holarse.web.defines.WebDefines; | ||
import java.io.UnsupportedEncodingException; | ||
import java.net.URLDecoder; | ||
import java.net.URLEncoder; | ||
import java.nio.charset.StandardCharsets; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.servlet.ModelAndView; | ||
|
||
@Controller | ||
@RequestMapping(value = "/search") | ||
public class SearchController { | ||
|
||
@PostMapping | ||
public ModelAndView searchForm(@RequestParam("q") final String q) throws UnsupportedEncodingException { | ||
return new ModelAndView(String.format("redirect:/search?q=%s", q)); //URLEncoder.encode(q, StandardCharsets.UTF_8.toString()))); | ||
} | ||
|
||
@GetMapping | ||
public ModelAndView search(@RequestParam("q") final String q, final ModelAndView mv) throws UnsupportedEncodingException { | ||
mv.setViewName("layouts/bare"); | ||
mv.addObject(WebDefines.DEFAULT_VIEW_ATTRIBUTE_NAME, "sites/search/results"); | ||
|
||
mv.addObject("q", q); //URLDecoder.decode(q, StandardCharsets.UTF_8.toString())); | ||
|
||
return mv; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<div class="container"> | ||
<div class="row"> | ||
Suchergebnisse für '<span data-th-text="${q}"></span>' | ||
</div> | ||
</div> |