The background data is transmitted to the foreground using the EL expression. The quotation marks and the following data are truncated:, el expression
Problem description:
The background data is transmitted to the foreground using the EL expression. The quotation marks and subsequent data are truncated:
For example:
Front-end page:
Html:
Solution:
1. A simple method is to write the input as follows:
<input type="text" name="data" value=' '>
Try the value in single quotes
2. A better method should be HTML Escape. It should be processed before data is transferred to the front-end. Use the relevant functions in java:
mav.addObject("data", toHtml(form.getData()));
Public static String toHtml (String s) {s = s. replace ("&", "& amp;"); s = s. replace ("<", "& lt;"); s = s. replace (">", "& gt;"); s = s. replace ("\ t", ""); s = s. replace ("\ r \ n", "\ n"); s = s. replace ("\ n", "<br>"); s = s. replace ("", "& nbsp;"); s = s. replace ("'", "& #39;"); s = s. replace ("\" "," & #34; "); s = s. replace ("\", "& #92;"); return s ;}// reverse public static String unHtml (String s) {s = s. replace ("<br>", "\ n"); s = s. replace ("& nbsp;", ""); s = s. replace ("& lt", "<"); s = s. replace ("& gt", ">"); s = s. replace ("& amp", "&"); return s ;}
3. js escape/