JAVA - Introduce Line break in request

September 3, 2014

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”;
    }