java struts action_Struts2 Action接口中的五个常量

Action接口所在包:

com.opensymphony.xwork2

Action接口中定义的五个常量:

public static final String ERROR

public static final String INPUT

public static final String LOGIN

public static final String NONE

public static final String SUCCESS

详细解释:

1、ERROR    返回错误

The action execution was a failure.Show an error view, possibly asking the user to retry entering data.

2、INPUT    返回输入页面

The action execution require more input in order to succeed. This result is typically used if a form handling action has been executed so as to provide defaults for a form. The form associated with the handler should be shown to the end user. This result is also used if the given input params are invalid, meaning the user should try providing input again.

3、LOGIN    返回登录界面

The action could not execute, since the user most was not logged in. The login view should be shown.

4、NONE    返回空,比如上传下载

The action execution was successful but do not show a view. This is useful for actions that are handling the view in another fashion like redirect.

5、SUCCESS    返回成功界面

The action execution was successful. Show result view to the end user.

代码:

LoginAction.java:

public String execute() {

if (userName.equals("admin")) {

return SUCCESS;

}

else {

return LOGIN;

}

}

struts.xml

/success.jsp

/login.jsp

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值