using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace WebProjects.Controllers
{
    public class HomeController : Controller
    {
        //
        // GET: /Home/
        public ActionResult Index()
        {
            return View();
        }
        [HttpGet]
        public ActionResult Login()
        {
            string loginUser = Request.QueryString["usercode"];
            string pwd = Request.QueryString["pwd"];
            if (loginUser == "admin" && pwd == "111")
            {
                return Json(new { success = true, msg = "登录成功" }, JsonRequestBehavior.AllowGet);
            }
            else
            {
                return Json(new { success = false, msg = "登录失败" }, JsonRequestBehavior.AllowGet);
            }
        }
        public ActionResult Admin(string usercode)
        {
            //根据usercode查询出密码pwd
            string pwd = "111";
            return RedirectToAction("Login", "Home", new { usercode = usercode, pwd = pwd });
        }
    }
}
@{
    Layout = null;
}
<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>首页</title>
    <script src="~/Scripts/jquery-1.7.1.min.js"></script>
    <script type="text/javascript">
        $(function () {
            $('#btnlogin').click(function () {
                var usercode = $('#usercode').val();
                var pwd = $('#pwd').val();
                $.ajax({
                    type: "Get",
                    url: "../Home/Login?usercode=" + usercode + "&pwd=" + pwd,
                    dataType: "json",
                    success: function (data) {
                        alert(data.msg);
                    }
                });
            });
        });
    </script>
</head>
<body>
    <div>
        用户名:<input type="text" id="usercode" />
    </div>
    <div>
        密码:<input type="password" id="pwd" />
    </div>
    <div>
        <input type="button" value="登录" id="btnlogin" />
    </div>
</body>
</html>

方法调用 Controller的Action 参数的更多相关文章

  1. struts2视频学习笔记 11-12(动态方法调用,接收请求参数)

    课时11 动态方法调用 如果Action中存在多个方法时,可以使用!+方法名调用指定方法.(不推荐使用) public String execute(){ setMsg("execute&q ...

  2. Struts2学习---基本配置,action,动态方法调用,action接收参数

    首先我们先来直接配置,然后再来讲原理: 第一步:jar包的引入: 我们可以到struts2的官网上下载: http://struts.apache.org/download.cgi#struts251 ...

  3. ASP.NET Core MVC中的IActionFilter.OnActionExecuting方法,可以获取Controller的Action方法参数值

    用过ASP.NET Core MVC中IActionFilter拦截器的开发人员,都知道这是一个非常强大的MVC拦截器.最近才发现IActionFilter的OnActionExecuting方法,甚 ...

  4. NopCommerce架构分析之五------Model绑定Action参数

    asp.net MVC中Action参数不只是一些基本类型,也支持实体参数.那么从客户端传来的数据如何映射或转换成实体对象呢?就是通过实体绑定类ModelBinder.此系列类在请求转化为后台Cont ...

  5. 在MVC或WEBAPI中记录每个Action的执行时间和记录下层方法调用时间

    刚才在博客园看了篇文章,http://www.cnblogs.com/cmt/p/csharp_regex_timeout.html  突然联想到以前遇到的问题,w3wp进程吃光CPU都挂起IIS进程 ...

  6. 在MVC过滤器中获取触发的Controller、Action、参数 等

    首先是实现接口System.Web.Mvc.IActionFilter的过滤器 获取Controller.Action.参数 方法一. string actionName = filterContex ...

  7. Struts2笔记2--动态方法调用和Action接收请求方式

    动态方法调用(在请求的时候,再明确具体的响应方法,配置的时候不明确): LoginAction类中有两个方法some和second 1. 动态方法的调用(修改常量struts.enable.Dynam ...

  8. Struts2中Action对象的set方法和get方法调用规则

    Struts的Action是采用的是多实例多线程设计,而不是像Servlet那样采用单实例多线程设计,因此在struts中,一个请求就对应一个Action对象,个对象之间的数据相互之间互不干扰.没接到 ...

  9. handlerAdapter与方法调用(参数的解析)

    前提:当找到handler以后,那么就要让handler发挥作用,这个时候handlerAdapter就派上用场了 这里面比较复杂就是requestMappingHandlerAdapter了,其他的 ...

随机推荐

  1. mysql数据库单表只有一个主键自增id字段,ibatis实现id自增

    mysql数据库单表只有一个主键自增id字段,ibatis实现id自增 <insert id="autoid">        insert into user_id ...

  2. Maven内置属性、POM属性

    1.内置属性(Maven预定义,用户可以直接使用) ${basedir}表示项目根目录,即包含pom.xml文件的目录; ${version}表示项目版本; ${project.basedir}同${ ...

  3. leetcode — edit-distance

    /** * Source : https://oj.leetcode.com/problems/edit-distance/ * * * Given two words word1 and word2 ...

  4. JQ-bootstrap我的开源前端框架

        因为实在不知道写啥,所以迟迟没有相关的介绍.但是必须要积累过程资产,所以还是介绍一下,不定哪天就有人用了.       首先还是介绍遇到的问题,我是做传统后台管理系统的,公司赶时髦,要用boo ...

  5. 开源项目filepond的独立自由之路:城市套路深

    微信原文更清晰:https://mp.weixin.qq.com/s/dv39XvvDNlDqvSgrhN2f7A 最近一直在做一个有关独立开发者友链联盟的插件项目,在做到上传头像时,满网络找最好的头 ...

  6. 安装Ubuntu的Mozilla Firefox的Adobe Flash Player时学习/lib、/usr/lib、/usr/local/lib的区别

    想对比一下Ubuntu和windows下视频效果体验的区别.安装了Ubuntu新版14.04.在之前的学习工程中,从来没想过使用虚拟机里的火狐浏览器看视频浏览网页,所以还真没有安装Flash的Linu ...

  7. [转]nodeJS中redis初步使用

    本文转自:https://blog.csdn.net/frankenjoy123/article/details/55209637 Node.js下使用Redis,首先: 1.有一台安装了Redis的 ...

  8. [转]用C#在windows上操控电脑自带蓝牙(入道指南)

    本文转自:https://blog.csdn.net/YSSJZ960427031/article/details/50990372 前言如题,如果你也想用C#在windows上操控电脑自带蓝牙,但是 ...

  9. JSTL_Core标记库

    一.   说明 如有转载,请标明出处 本博讲解JSTL中的core库 对标记属性进行介绍时,首先介绍必写的属性,然后带有默认值的属性,其次是其余属性,这三类属性中间用空行隔开 二:core标记库库 C ...

  10. software testing

    Software Testing Software testing is the process of evaluation a software item to detect differences ...