How to Create a JSP template by using myeclipse 9.0

Source: Internet
Author: User

Create a new JSP page in myeclipse, in order to make the page display Chinese, we always want to do the page instruction pageencoding = "UTF-8" or pageencoding = "GBK" and other actions, every time you create a page, you need to change it once, which is quite troublesome. I have found a solution on the Internet to solve this problem by creating my own JSP template. Here I will summarize the steps of the method below: 1. First, disable myeclipse9. If myeclipse9 is not disabled, you cannot modify all the content in the installation directory of myeclipse9. The following operations cannot be performed;

2. In the installation directory of myeclipse9, find
D: \ Program Files \ myeclipse 9.0 \ common \ plugins \ com. genuitec. Eclipse. wizards_9.0.0.me201103012021.jar
Here: 9.0.0 is the version number, and 201103012021 may be the Compilation Time or packaging time. Your values may be different, but others will be the same.

3. Open it with RAR or decompress the software and enter the Templates \ JSP folder. Many templates are displayed.

4. Copy a template (for example, JSP. VTL ).

5. Modify the template you copied (use the notebook or editplus to open it ). For example, first change the file name to jspofserein. VTL, and then open the template and modify the Code as follows:
#*---------------------------------------------## Template for a JSP<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%><%@ page contentType=" text/html; charset=UTF-8"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

6. Save the modification and add it to the com. genuitec. Eclipse. wizards_9.0.0.me201103012021.jar package (directly pull it into the Templates \ JSP folder opened with the compressed package ).

7. Return to the root directory (COM. genuitec. eclipse. wizards_9.0.0.me201103012021.jar directory), find the template configuration file templates. XML, which can be opened in the same notebook or editplus for modification. Modify as follows: add the following elements in <templatelibrary>;

<templatecontext="com.genuitec.eclipse.wizards.jsp"script="templates/jsp/JspOfSerein.vtl"name="Serein-JSP template"/>
Where:
1. templates/JSP/jspofserein. VTL: the template and Relative Path Modified and added in step 5.
2. serein-JSP template: name of the template to be identified in myeclipse. When creating a JSP file in myeclipse, use this name to select the corresponding template.
3. Context = "com. genuitec. Eclipse. Wizards. jsp" must exist and be copied just like other JSP template settings.

8. After the modification is complete, set templates. XML is also saved (saved to the desktop) to be used, and then com. genuitec. eclipse. templates in the wizards_9.0.0.me201103012021.jar package. XML deletion, and finally the modified templates. add XML to complete the replacement and modification. 9. re-open myeclipse9 and click New/JSP. In the "template to use" drop-down box of the JSP new Wizard, the newly created template -- serein-JSP template, see the figure below: click "finish" to complete JSP creation. The resulting JSP page template code is as follows:
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%><%String path = request.getContextPath();String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

This method should be applicable to creating and adding other templates! Reference Source: http://panyongzheng.iteye.com/blog/1102081http://iscode.iteye.com/blog/628548

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.