如何从中检索具有特定键的消息Stripes 框架
我想从 Stripes 框架的标签中检索具有特定键的消息。
在操作 bean 中,我有这个:
switch (result) {
case REG_ALREADY_REGISTERED:
getContext().getMessages().add(new LocalizableMessage("consumer.already.registered"));
redirect = getContext().getSourcePageResolution();
break;
在 JSP 页面中:
<stripes:messages key="consumer.already.registered"/>
但上面的代码似乎不起作用。如果我只输入“
”,它会显示 stripes 打印消息的默认方式。即,用“ul li”的东西。我想对这些消息进行我自己的介绍。 JSP 有什么可能吗,如下所示:
<c:if test="${not empty actionBean.context.messages}">
<c:out value="${actionBean.context.messages......"/> //This is the place where I am unsure
</c:if>
I want to retrieve a message with a specific key from the tag of Stripes framework.
In the action bean I have this:
switch (result) {
case REG_ALREADY_REGISTERED:
getContext().getMessages().add(new LocalizableMessage("consumer.already.registered"));
redirect = getContext().getSourcePageResolution();
break;
In the JSP page:
<stripes:messages key="consumer.already.registered"/>
but the above code does not seem to work. If I am putting only the "<stripes:messages/>
" it shows stripes's default way of printing messages. i.e, with "ul li" thing. I want to give my kind of presentation to the messages. Is there anything possible with JSP like as follows:
<c:if test="${not empty actionBean.context.messages}">
<c:out value="${actionBean.context.messages......"/> //This is the place where I am unsure
</c:if>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有一个功能请求已提交,要求具有用于显示消息的附加标签: http://www.stripesframework .org/jira/browse/STS-245。
如果您不喜欢默认的消息页眉和页脚,您只需按照文档中所述通过属性更改它们: http://stripes.sourceforge.net/docs/current/taglib/stripes/messages.html。不过,这将更改所有页面的页眉和页脚。如果您想更改某个特定页面的它们,据我所知,除了执行以下操作之外,没有其他方法:
其中
myFn:getMessageText
是一个如下定义的函数:There is a feature request filed to have additional tags for displaying messages : http://www.stripesframework.org/jira/browse/STS-245.
If what you don't like is the default messages headers and footers, you just have to change them through the properties as described in the documentation: http://stripes.sourceforge.net/docs/current/taglib/stripes/messages.html. This will change the headers and footers for all your pages, though. If you want to change them for one specific page, There is no other way, AFAIK, than doing something like this:
Where
myFn:getMessageText
would be a function defined like this: