[英]The difference between return statements in struts 2
What is the difference between returning a SUCCESS
and Action.SUCCESS
for your execute method in struts 2? 在struts 2中为您的execute方法返回
SUCCESS
和Action.SUCCESS
有什么区别? I know about returning a SUCCESS
string, but I couldn't figure the Action.SUCCESS
one? 我知道返回一个
SUCCESS
字符串,但是我无法弄清楚Action.SUCCESS
一个吗?
Action.SUCCESS
is a String
constant defined in the Action
interface. Action.SUCCESS
是在Action
接口中定义的String
常量。 see here 看这里
It will be available in all your Action classes that implement this interface. 在实现此接口的所有Action类中,它将可用。 Your own action classes inherit this constant.
您自己的动作类继承了此常数。
So there is practically no difference between Action.SUCCESS
and SUCCESS
inside a class that implements Action
. 因此,在实现
Action
的类中, Action.SUCCESS
和SUCCESS
实际上没有区别。
They are the same if point to the same constant in Action
class. 如果在
Action
类中指向相同的常量,则它们是相同的。 But to use the first case required either the action class to implement the Action
interface better with extending the ActionSupport
which implements the Action
interface or use static imports. 但是,使用第一种情况需要无论是动作类来实现
Action
与扩展更好的界面ActionSupport
它实现了Action
界面还是使用静态进口。 The second case is the usual way to access static resources. 第二种情况是访问静态资源的常用方法。
They are both string mapped to "success" string. 它们都被字符串映射到“成功”字符串。
public interface Action {
/**
* The action execution was successful. Show result
* view to the end user.
*/
public static final String SUCCESS = "success";
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.