0
点赞
收藏
分享

微信扫一扫

struts2 的 result 的 type


默认:dispatcher 可不写 转向 jsp 页面,jsp页面前要加"/"

@Action(value = "showPostsById", results = {
@Result(name = Constants.SUCCESS, location = "/post.jsp")})




如果是跳转到另一action,而且必须传递值


那么type=chain


@Action(value = "leaveWord", results = {
@Result(name = Constants.SUCCESS, location = "/friend.jsp"),
@Result(name = Constants.INPUT,type="chain", location = "${nextAction}")})





重定向到新页面,新页面显示跳转后的action


@Result(type="redirect", name = Constants.SUCCESS, location = "showPostsById.action?fpid=${fpid}")





如果要用动态location


那么,定义全局变量 nextAction,然后get(),set()


然后在action中把要去的action赋给nextAction


上面的配置就是动态location



注意:


如果type=chain,那么location='******',而不能是*****.action


如果type=redirect 那么,必须是location='******.action'


如果是dispatcher ,那么,就要location='/******.jsp',要加"/"


举报

相关推荐

0 条评论