The solution for saving JSP files to the database in the lost format is: jsp Database

Source: Internet
Author: User

The solution for saving JSP files to the database in the lost format is: jsp Database

What is the storage of articles on the website? Oralce is used for CLOB storage. There are many methods for Java to operate CLOB on the Internet. However, it is found that the format displayed on the webpage after reading is completely different from the format entered at the time, and this paragraph no longer exists.

Because the textarea tag is used on the page rather than the powerful webpage text editor, you have to handle the format problem by yourself. Below is a professional function I found, use it to escape the text string sent from the front-end and store it in the database. This time, the text that is read again shows paragraphs.

Solution code reference:

/*** Format the document information to keep the document format. Used for saving. ** @ Param str * @ return */public String HTMLEncode (String str) {str = str. replace (">", ">"); str = str. replace ("<", "<"); char ch; ch = (char) 32; // space str = str. replace (String. valueOf (ch), ""); ch = (char) 34; // ''str = str. replace (String. valueOf (ch), "); ch = (char) 39; // 'str = str. replace (String. valueOf (ch), "'"); ch = (char) 13; // carriage return str = str. replace (String. valueOf (ch), ""); ch = (char) 10; // new line str = str. replace (String. valueOf (ch), "<BR>"); return str ;}

The above is the solution to saving JSP files to the lost format of the database. I hope it will be helpful for you to learn and have good ideas.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.