[HttpPost]
public ActionResult StudentList( string StudName, string studName, DateTime BirthDay, FormCollection form, string controller, string Action, StudentModels student)
{
//其中StudName为aspx页面中标签的name属性(StudName不区分大小写)
//其中BirthDay为页面中标签的name属性(类型可自己指定【需转换成功才可以】,这里为DateTime)同样BirthDay不区分大小写
//其中controller,Action为路由信息(controller,Action不区分大小写)
//FormCollection包含了post回来的信息 通过form[]来取值
//如果使用强类型绑定 可通过实体回传值 这里实体为StudentModels
//同样可以使用Request.Form[] Request.QueryString[] Request[] 来取值 不过此Request非WebForm中的Request 这里的Request是RequestBase抽象类的实例 WebForm中Request是封装类 HttpRequest的实例 #region 到要经过执行controller里方法后 显示出页面。
//return RedirectToAction("Index");//可跳出本controller
//return RedirectToRoute(new {controller="Home",action="Index"});//可跳出本controller
//Response.Redirect("Index");//只能使用本controller下的方法名称。返回值为void
//return Redirect("Index");//只能使用本controller下的方法名称。
#endregion #region 直接显示出对应的页面 不经过执行controller的方法。
//return View("Index");//被controller 的其他视图//return View("~/Views/Home/Index.aspx");//任意controller下的其他视图
#endregion
return View();
}
            //重定向跳转 到指定视图
//1. 使用视图名称创建一个呈现视图的 System.Web.Mvc.ViewResult 对象。(不经过Action 方法)
return View("RedirectOne");
return View("~/Views/Two/RedirectOne.cshtml"); //重定向跳转 到本controller下的action
return Redirect("RedirectOne");
Response.Redirect("RedirectOne");
return null; //重定向跳转 到其他或本controller下的action
//本controller
return RedirectToAction("RedirectOne");
//其他controller
return RedirectToAction("MasterOne", "One");
//本controller
return RedirectToRoute(new { action = "RedirectOne" });
//其他controller
return RedirectToRoute(new { controller = "One", action = "MasterOne" });
            //跨区域 重定向
//其他controller
return RedirectToAction("Index", "BlogIndex", new { area="Blog"});
return RedirectToRoute( new { area = "Blog" ,controller="BlogIndex",action="Index"});

4.加载其他视图的方式

        //返回 其他的视图,不经过controller
//可以 传递 model 参数
public PartialViewResult PartialTwo()
{
List<string> list = new List<string>() {
"姓名",
"密码"
};
return PartialView(); return PartialView("PartialOne", list);//本controller 下的视图,带参数 return PartialView("~/Views/Redirect/PartialOne.cshtml", list);//其他controller 下的视图 带参数 return PartialView("~/Views/LayoutOne/PageOne.cshtml");//其他controller 下的视图
}

Action重定向总结的更多相关文章

  1. struts2 action重定向

    struts2的结果类型: <action name="loginAction" class="com.itheima.action.LoginAction&quo ...

  2. ASP.Net MVC Action重定向跳出Controller和Area

    1.重定向方法简介 [HttpPost] public ActionResult StudentList( string StudName, string studName, DateTime Bir ...

  3. struts2 action重定向action中文乱码处理

    比如:Action方法productCategorySave()变量message,传递给Action方法productCategoryAdd(),当变量message为中文变量时,要进行编码设置,不 ...

  4. Asp.net Mvc Action重定向总结

    摘自博客园 程晓晖 [HttpPost]        public ActionResult StudentList( string StudName, string studName, DateT ...

  5. Struts1 action重定向跳转 带参数

    ActionForward forward = new ActionForward("kmRentalMain.do?method=view&fdId="+id);forw ...

  6. 20SpringMvc_结果的转发可共享参数;重定向不能共享参数

    Normal 0 7.8 磅 0 2 false false false EN-US ZH-CN X-NONE MicrosoftInternetExplorer4 /* Style Definiti ...

  7. struts2视频学习笔记 03-06(Struts 2配置文件无提示问题,Action配置中的各项默认值,各种转发类型)

    课时3 解决Struts 2配置文件无提示问题(eclipse):window→preference→XML→XML Catlog

  8. Struts2之Action接收请求参数和拦截器

    技术分析之在Struts2框架中使用Servlet的API        1. 在Action类中也可以获取到Servlet一些常用的API        * 需求:提供JSP的表单页面的数据,在Ac ...

  9. Struts2中Action之ResultType

    我们在struts-defalut.xml文件中可以看到如下图所示: 这些类型是配置文件所带的.接下来我们主要讲解我标注出来的这个,其他的我就不做详解了,有兴趣的可以去试试. web.xml文件我在这 ...

随机推荐

  1. 使用OpenXml实现生成数据字典文档(beta)

    最近项目在走验收流程,之前没有仔细看SOW文档,发现需要补好多份文档,其中就有数据字典,项目组不愿意花时间太多的时间弄这些文档,也不希望以后还要重复劳动力,最终决定做一个工具,方便自己生成数据字典文档 ...

  2. 3.Android Studio系列教程3——快捷键

    原文链接:http://stormzhang.com/devtools/2014/12/09/android-studio-tutorial3/   一.更新Android Studio 项目根目录的 ...

  3. [Jquery] 操作html 不常用元素方法大全

    除http://www.w3school.com.cn/jquery/jquery_selectors.asp上的以外该大全应都有. 第一章 input控件篇 1.操作select 下拉框 1.1 获 ...

  4. MySql用statement实现DDL,DML,DQL的操作Demo

    Demo1 Connection connection=null; Statement stmt=null; int result=-1; try { Class.forName("com. ...

  5. JDK6和JDK7中的substring()方法

    substring(int beginIndex, int endIndex)在JDK6与JDK7中的实现方式不一样,理解他们的差异有助于更好的使用它们.为了简单起见,下面所说的substring() ...

  6. U盘装系统系列一—-安装老毛桃U盘启动制作工具

    今天跟大家分享下如何制作U盘启动盘,通过U盘启动来安装操作系统.U盘便于携带,同时能解决光驱出问题装不了系统的麻烦,可谓是装机利器!我一直用的都是老毛桃的U盘启动制作工具,很好用,很强大,就以它来演示 ...

  7. Ubuntu与Ubuntu系统之间的mount挂载

    1.被挂载机 1>安装Ubuntu nfs apt-get install nfs-kernel-server 2>配置/etc/exports Ubuntu nfs允许挂载的目录及权限在 ...

  8. linux 下 重启apache

    重启 apache #service httpd restart

  9. Codeblocks 添加库(undefined reference 错误的处理)

    静态库  (扩展名为 .a 或 .lib) 是包含函数的文件,用于在link阶段整合执行程序,动态链接库(扩展名  .dll)是不在link阶段整合进执行程序中的. DLL文件在执行阶段动态调用 下面 ...

  10. openpyxl

    openpyxl库的使用,这个处理xlsx还是挺有用的 ref:传送门 from openpyxl import Workbook from openpyxl import load_workbook ...