版权声明:尊重原创,转载请标明出处 https://blog.csdn.net/jifgjifg/article/details/78047255
使用 <s:fielderror/>
或 <s:fielderror fieldName="键" />
在 jsp 页面输出 validate() 中 addFieldError() 添加的报错信息时,会包含ul li 标签。这可能不是你想要的。下面看看如何把 ul li 标签去掉。
找到 struts2 核心文件,我的是 struts2-core-2.3.16.3,解压,在里面 template\simple 文件夹中找到 fielderror.ftl,这就是 <s:fielderror/>
的输出格式的配置文件。
修改这个文件,相信你自己能搞定的,把<ul> <li>
标签去掉就好。
然后,在你的项目的 src 文件夹中,新建 template 文件夹,然后在 template 文件夹中新建 simple 文件夹(或者新建一个template.simple包),把修改后的 fielderror.ftl 放到 simple 文件夹中
最后,修改struts2的配置文件 struts.xml 文件,在节点里添加
<constant name="struts.ui.theme" value="simple" />
重新编译一下你的项目吧