POSTS

JAVA - Introduce Line break in request

In the example bellow the recipe description had something like:

    100ml milk\r\n10g sugar

which in html corresponded to the following textarea contents:

    100ml milk
    10g sugar

    @RequestMapping(“/submitRecipe”)
    public String submitRecipe2(Model model, @ModelAttribute Recipe recipe, HttpServletRequest request) {
        model.addAttribute(“recipe”, recipe.getDescription().replace(”\r\n”, “%0A”));
        return “result2”;
    }