unterminated string literal

use

Java code    Collection Code
  1. ServletActionContext.getResponse().getWriter()  

When the front desk to write information, often unterminated string literal error: unterminated string constants, most likely due to the presence of the string line breaks caused. Presence \ r \ n

Solution:

Before the result is written to the foreground, the special symbol rows string escaped out of exchange,

Java code    Collection Code
  1. PrintWriter pw = ServletActionContext.getResponse().getWriter();  
  2. result = result.replace("\n\r""<br>&nbsp;&nbsp;");  
  3. result = result.replace("\r\n""<br>&nbsp;&nbsp;");  
  4. result = result.replace("\t""&nbsp;&nbsp;&nbsp;&nbsp;");  
  5. result = result.replace(" ""&nbsp;");  
  6.   
  7. result = result.replace("\"""\\" + "\"");  
  8. pw.print(result);  

Reproduced in: https: //my.oschina.net/xiaominmin/blog/550879

Guess you like

Origin blog.csdn.net/weixin_34007879/article/details/92520287