【发布时间】:2016-09-11 07:46:41
【问题描述】:
在我的网络应用程序中有一个编辑表单,使用英语时一切正常,但是当我尝试用俄语创建新的测试记录时,我得到了类似的东西,在提交表单后:На русском тес&#1090 而不是 @987654322 @...
我的html表单:
<form th:action="@{'/save/' + ${recipe.id}}" method="post" th:object="${recipe}">
<input type="hidden" id="recipeIdInput" th:field="${recipe.id}" th:value="${recipe.id}"/>
<input type="hidden" id="recipeFavorite" th:field="${recipeFavorite}" th:value="${recipeFavorite}"/>
<div th:each="favUser, stat : ${recipe.favoriteUsers}" hidden="hidden">
<input hidden="hidden" th:id="@{'favUser' + ${stat.index}}" th:value="${favUser.username}"/>
</div>
<p hidden="hidden" id="recipeId" th:text="${recipe.id}"/>
<p hidden="hidden" id="recipeUserName" th:text="${recipe.user.username}"/>
<div class="grid-100 row controls">
<div class="grid-50">
<h2> Recipe Editor </h2>
</div>
<div class="grid-50">
<div class="flush-right">
<button type="submit">Save Recipe</button>
<a href="/"><button type="button" class="secondary">Cancel</button></a>
</div>
</div>
</div><div class="clear"></div>
<div class="grid-100 row">
<div class="grid-20">
<p class="label-spacing">
<label> Name </label>
</p>
</div>
<div class="grid-40">
<p>
<input id="recipeName" type="text" th:placeholder="${recipe.name}" th:field="${recipe.name}"/>
</p>
</div>
<div class="grid-40">
我的控制器:
@RequestMapping(path = "/save/{id}", method = RequestMethod.POST)
public String saveRecipe(@ModelAttribute @Valid Recipe recipe, BindingResult result, @PathVariable Long id, RedirectAttributes attributes) {
recipe.setUser(getLoggedUser());
if (recipe.getCategory() != null)
recipe.setCategory(categoryService.findById(recipe.getCategory().getId()));
recipe.setFavoriteUsers(recipeService.findById(recipe.getId()).getFavoriteUsers());
recipe.setPhoto(recipeService.findById(recipe.getId()).getPhoto());
if (result.hasErrors()) {
for (ObjectError o : result.getAllErrors())
attributes.addFlashAttribute("flash",new FlashMessage(o.toString(), FlashMessage.Status.FAILURE));
attributes.addFlashAttribute("recipe", recipe);
attributes.addFlashAttribute("recipeFavorite", recipe.isFavorite(getLoggedUser()));
return "redirect:/edit/"+id;
}
recipeService.save(recipe);
attributes.addFlashAttribute("flash", new FlashMessage("Recipe saved.", FlashMessage.Status.SUCCESS));
return "redirect:/";
}
那么,那些漂亮的俄语字母会发生什么以及如何解码呢? 提前致谢。
【问题讨论】:
标签: java spring web-applications encode