struts2.0 Action 通配符的问题

helloqiner 2008-08-28 11:27:40
struts2.0中的action是支持通配符映射的。但是它的返回值对应页面是否支持通配呢?
如下面这个action定义,其中result name同页面存放路径是对应的:
<action name="ask" class="com.test.web.action.AskAction">
<result name="010" type="freemarker">fm/010/Ask.html</result>
<result name="020" type="freemarker">fm/020/Ask.html</result>
<result name="030" type="freemarker">fm/030/Ask.html</result>
<result name="040" type="freemarker">fm/040/Ask.html</result>
<result name="050" type="freemarker">fm/050/Ask.html</result>
......
</action>
那么能否这样定义,来实现返回值的通配呢?
<action name="ask" class="com.test.web.action.AskAction">
<result name="*" type="freemarker">fm/{1}/Ask.html</result>
</action>
...全文
320 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
luojm2003 2010-09-03
  • 打赏
  • 举报
回复
我也正想了解一下通配符的使用!
kedakeda 2008-08-29
  • 打赏
  • 举报
回复
你可以定义全局页面啊
就是global
这样在没有指定页面的时候自动返回全局页面
海会圣贤 2008-08-29
  • 打赏
  • 举报
回复
正想学strust 2呢,还只能算是了解,帮不了
eagle_speed 2008-08-29
  • 打赏
  • 举报
回复
fm/{1}/Ask.html 此处的{1}取得是你action 标记里的name的值
starisme 2008-08-29
  • 打赏
  • 举报
回复
如果你原来配置可以正常运行的话,
<action name="ask" class="com.test.web.action.AskAction">
<result name="010" type="freemarker">fm/${id}/Ask.html </result>
</action>
helloqiner 2008-08-29
  • 打赏
  • 举报
回复
没有人遇到过这样的问题吗?
zhao_tk 2008-08-28
  • 打赏
  • 举报
回复
没用过,帮顶,关注
zhanlaohu 2008-08-28
  • 打赏
  • 举报
回复
那么能否这样定义,来实现返回值的通配呢?
<action name="ask.action" class="com.test.web.action.AskAction">
<result name="*" type="freemarker">fm/{1}/Ask.html </result>
</action>

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧