java - Uncaught SyntaxError: Unexpected token ILLEGAL -


i have following code (jsp)

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%> <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>     <script type="text/javascript">       $(document).ready(function() {            <c:foreach items="${messages}" var="msg"  varstatus="i">              alert("${msg.description}");           </c:foreach>       });  </script> 

ans messages arraylist passed jsp controller.

    model.addattribute("messages", messages);      return "the_above_jsp"; 

this working fine until description value hold following string value.

new task assigned project hip tensile strength analysis : data management/analysis task due date 20140408

when description has value show error uncaught syntaxerror: unexpected token illegal

why ?

i solved issue removing newline characters string description when set attribute , pass jsp.

    for(int i=0;i<messages.size();++i){         messages.get(i).setdescription(messages.get(i).getdescription().replaceall("\n", ""));               }       model.addattribute("messages", messages);      return "the_above_jsp"; 

but have no idea how worked. may illegal character newline character. or there may better explanation. please modify or add new answer though solved in wild guess.


Comments

Popular posts from this blog

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -

python 3.x - Mapping specific letters onto a list of words -