标签:
如果是simple 主题,还会自动显示错误消息吗? 如果不会显示,怎么办?类 和 配置 详见:
修改页面如下:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<s:debug></s:debug>
<s:form action="testConversion" theme="simple">
Age:<s:textfield name="age" label="Age"></s:textfield>
<br>
显示错误消息的方式一 :${fieldErrors.age[0] }
<br>
显示错误消息的方式二: <s:fielderror fieldName="age"></s:fielderror>
<br>
<s:submit></s:submit>
</s:form>
</body>
</html>
效果:
而 错误消息二 的显示效果巨丑,改善方式是:
若是 simple 主题, 且使用 <s:fielderror fieldName="age"></s:fielderror> 来显示错误消息, 则该消息在一个 ul, li, span 中. 如何去除 ul, li, span 呢 ?
在 src 下新建 template.simple 包, 新建 fielderror.ftl 文件, 把原生的 fielderror.ftl 中的内容 复制到新建的 fielderror.ftl 中, 然后剔除 ul, li, span 部分即可.
原来数据结构
改完以后
改完以后的显示效果
标签:
原文地址:http://blog.csdn.net/chuck_kui/article/details/51363432