Eclipse Custom Variable for Java Code Templates

前端 未结 7 1096
予麋鹿
予麋鹿 2020-12-30 09:38

How do you add a new variable to be inserted into a Java code template. How do I add a variable to the list in Window->Preferences->Java->Code Style->Code Templates->Code->N

相关标签:
7条回答
  • 2020-12-30 10:16

    To add on to the conversation, I also wanted to insert a custom variable into a template. My issue was that I wanted to insert a variable from jsp/jstl definition inside the template.

    (I.E. <c:set var="myVariable" value="${requestScope.variableName}" />)

    This apparently caused some issues because templates already use the ${} syntax to help resolve its own variables.

    So simple solution I included an additional $ to the pattern in the template. Two $$ signs resolves it to a single $ sign, hence giving me exactly what I wanted. Hopefully this helps the poster or someone with similar situation.

    0 讨论(0)
提交回复
热议问题