一个动作可以有两种方法? [英] One action can have two method?

查看:107
本文介绍了一个动作可以有两种方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在asp.net中,一个控制器可以有很多的ActionResult返回多方面的。

in asp.net, one controller can have many ActionResult return many ways.

public class HomeController : Controller
{
    public ActionResult Index()
    {
        ViewBag.Message = "Modify this template to jump-start your ASP.NET MVC application.";

        return View();
    }

    public ActionResult About()
    {
        ViewBag.Message = "Your app description page.";

        return View();
    }

    public ActionResult Contact()
    {
        ViewBag.Message = "Your contact page.";

        return View();
    }
}

如何做到这一点在Java中Struts2的,人们的行动只有一个执行一个能够返回的途径之一。

how to do it in Java Struts2, one Action have only one execute that able to return one way.

推荐答案

有只有一个首页在你的榜样,就像只有一个执行在S2的行动。

There's only one Index in your example, just like there's only one execute in an S2 action.

操作可能,但是,有方法的任意数目。这些方法可以以多种方式被调用,包括通过注解,XML配置,或通过使用公约插件 REST插件

Actions may, however, have an arbitrary number of methods. Those methods may be called in a number of ways, including configuration via annotations, XML, or by using the Convention plugin or REST plugins.

在你的榜样,你没有表现出一种方法返回多种方式,展示多个动作返回多种方式,其以类似的方式Struts 2的支持下

In your example you don't show one method returning multiple ways, you show multiple actions returning multiple ways, which is supported under Struts 2 in similar ways.

这篇关于一个动作可以有两种方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆