2

I have webmvc application with jsp-page as a view.

Here one of my mapping methods:

@RequestMapping("vacancy/{id}")
public String showVacancy(@PathVariable String id, Model model) {

    Vacancy vacancy = vacancyRepository.findOne(new ObjectId(id));
    model.addAttribute("description", vacancy.getDescription());

    return "vacancy";

}

Here the part of vacancy.jsp:

<body>

<h1><c:out value="${title}"/></h1>
<hr>

<h2>Description</h2>
<c:out value="${description}"/>

</body>

As you can see, I trying to send description to jsp-attribute ${description}. The problem here is in that description. It has html-tags. For example

<p><strong>Responsibilities:</strong></p>

And after rendering I get quite strange html page that includes that description with all tags :(

How can I fix it?

2
  • Could you please add response page? Commented Nov 19, 2015 at 15:38
  • Response page is the same as description = "<p><strong>Responsibilities:</strong></p>" (that tags don`t render to html-view, just plain text) Commented Nov 21, 2015 at 19:29

1 Answer 1

1

You pass html the same way you pass text. You just need the jtsl code to not escape the html by using the escapeXml="false" directive.

For example:

<c:out value="${fn:replace(row.entryText, newLineChar, '<br>')}" escapeXml="false" />
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.