用户可以搜索我的列表中的内容
<form action="/worldoffragrance">
<input name="search"/>
<input type="submit" value="search"/>
&#13;
如果列出它是空的,我想建立另一个网站,用户可以放置他想要的东西,我该如何解决这个问题? :)
@RequestMapping("/")
public String fragrance() { return "fragrance"; }
@RequestMapping("/worldoffragrance")
public String worldoffragrance(
@RequestParam(value = "search") String search,
@RequestParam(value = "operation", required = false, defaultValue = "search") String operation, Model model) {
List<Fragrance> matchingPerfumes = advisor.findMatchingPerfume(search);
if (matchingPerfumes.isEmpty()) {
return "redirect:/fragrancenotfound";
}
model.addAttribute("matchingPerfumes", matchingPerfumes);
return "result";
}
@RequestMapping("/fragrancenotfound")
public String fragranceNotFound(
@RequestParam(value = "name", required = true) String getName,
@RequestParam(value = "ingredients", required = true) String getIngredients,
@RequestParam(value = "operation", required = false, defaultValue = "add" ) String operation, ModelMap model)
{
model.addAttribute("getName", "getIngredients");
return "redirect: /createNewFragrance";
}
@RequestMapping("/createnewfragrance")
public String createnewfragrance() {
return "createNewFragrance";}
答案 0 :(得分:0)
您正在重定向到/fragrancenotfound
,其中包含您未提供的必需参数name
(和ingredient
)。提供这些值或使它们不是必需的