如何在java注解中加入原生html标签内容

时间:2023-03-10 06:09:32
如何在java注解中加入原生html标签内容

你是否也遇到过类似的事情.想在java注解加入类似于下面这种注释:

如何在java注解中加入原生html标签内容

结果出来却变成了这样 ,标签被解析了, 这怎么办呢 :

如何在java注解中加入原生html标签内容

且看分解

我们在注解中直接放入下边这样的代码:

<Response>
<Result>X</Result>
<Resolution width="xx" .../>
<Data>xxxxxxxxxxxx...............</Data>
</Response>

就是下边这样直接放入<p></p>这对标签中:

如何在java注解中加入原生html标签内容

然后显示是这样的!!!! 格式全没了,是不是很蛋疼:

如何在java注解中加入原生html标签内容

我们想要的是最开始的那种, 只需这样:

* <pre>
* {@code
*   <Response>
*   <Result>..</Result>
*  </Response>
*  }
* </pre>​

把你的html 标签内容放到<pre>{@code  你的代码 }</pre> 这样就可以了...

经测试, <pre>与@code 缺一不可....

说明下:

<pre>:这个标签是html中保持html样式输出的标签;

@code: 是java的注解

转发注明出处: http://www.cnblogs.com/jycboy/p/java_annotation_addhtml.html