MVVMLight学习笔记(五)---RelayCommand深究
一、概述
有时候,单纯的命令绑定不一定能满足我们的开发需求,比如我们需要在命令绑定的时候传递一个参数,这个时候,我们就需要使用RelayCommand的泛型版本了。
RelayCommand的泛型版本的构造函数以下:
public RelayCommand(Action<T> execute, bool keepTargetAlive = false);
public RelayCommand(Action<T> execute, Func<T, bool> canExecute, bool keepTargetAlive = false);
构造函数传入的是委托类型的参数,Execute 和 CanExecute执行委托方法。
二、带一个参数的命令绑定
代码片段如下:
<StackPanel>
<GroupBox Header="带string类型参数的命令" BorderBrush="#FF11519C" BorderThickness="1" FontSize="16" Foreground="#FFCDAA0C" Margin="2">
<StackPanel>
<StackPanel Orientation="Horizontal">
<Label Content="UserList:" VerticalContentAlignment="Center" FontSize="20" ></Label>
<Label Content="{Binding Path=UserList,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" FontSize="20" />
</StackPanel>
<StackPanel Orientation="Horizontal">
<Label Content="UserName:" VerticalContentAlignment="Center" FontSize="20" ></Label>
<TextBox Width="200" Name="tbUser"></TextBox>
<Button Content="AddUser" Command="{Binding AddUserCommand}" CommandParameter="{Binding ElementName=tbUser,Path=Text}"></Button>
<CheckBox Content="IsCanAdd" VerticalAlignment="Center" FontSize="16" IsChecked="{Binding IsCanAddUser, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"></CheckBox>
</StackPanel>
</StackPanel>
</GroupBox>
</StackPanel>
private RelayCommand<string> addUserCommand; public RelayCommand<string> AddUserCommand
{
get
{
if (addUserCommand == null)
{
addUserCommand = new RelayCommand<string>(AddUser, (string p) => { return IsCanAddUser; });
}
return addUserCommand;
}
set { addUserCommand = value; }
}
private void AddUser(string par)
{
UserList = UserList + " " + par;
}
三、带多个参数的命令绑定
给命令传递多个参数,建议使用以下方式:
使用MultiBinding将多绑定的各个值转换成我们所需的对象或者实例模型,再传递给ViewModel中的命令。
代码片段如下:
<Window x:Class="MvvmLightDemo1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:MvvmLightDemo1"
xmlns:cvt="clr-namespace:MvvmLightDemo1.Converter"
xmlns:mvvm="http://www.galasoft.ch/mvvmlight"
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
mc:Ignorable="d"
Title="MVVMLIghtDemo1" Height="500" Width="700" >
<Window.Resources>
<cvt:UserInfoConverter x:Key="userInfoConverter"></cvt:UserInfoConverter>
</Window.Resources>
<Window.DataContext>
<Binding Path="Main" Source="{StaticResource Locator}"></Binding>
</Window.DataContext>
<StackPanel>
<StackPanel>
<GroupBox Header="带string类型参数的命令" BorderBrush="#FF11519C" BorderThickness="1" FontSize="16" Foreground="#FFCDAA0C" Margin="2">
<StackPanel>
<StackPanel Orientation="Horizontal">
<Label Content="UserList:" VerticalContentAlignment="Center" FontSize="20" ></Label>
<Label Content="{Binding Path=UserList,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" FontSize="20" />
</StackPanel>
<StackPanel Orientation="Horizontal">
<Label Content="UserName:" VerticalContentAlignment="Center" FontSize="20" ></Label>
<TextBox Width="200" Name="tbUser"></TextBox>
<Button Content="AddUser" Command="{Binding AddUserCommand}" CommandParameter="{Binding ElementName=tbUser,Path=Text}"></Button>
<CheckBox Content="IsCanAdd" VerticalAlignment="Center" FontSize="16" IsChecked="{Binding IsCanAddUser, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"></CheckBox>
</StackPanel>
</StackPanel>
</GroupBox>
</StackPanel> <StackPanel>
<GroupBox Header="带对象类型参数的命令" BorderBrush="#FF11519C" BorderThickness="1" FontSize="16" Foreground="#FF127C0D" Margin="2">
<StackPanel>
<StackPanel Orientation="Horizontal">
<Label Content="UserName:" FontSize="16" ></Label>
<TextBox Width="200" Name="tbxUser" FontSize="16" />
<Label Content="Password:" FontSize="16" ></Label>
<TextBox Width="200" Name="tbxPwd" FontSize="16" />
<Button Content="AddUser" Command="{Binding AddUserCommandWithObjPar}">
<Button.CommandParameter>
<MultiBinding Converter="{StaticResource userInfoConverter}">
<Binding ElementName="tbxUser" Path="Text"/>
<Binding ElementName="tbxPwd" Path="Text"/>
</MultiBinding>
</Button.CommandParameter> </Button>
</StackPanel>
<StackPanel Orientation="Horizontal">
<Label Content="Parameter:" FontSize="16" ></Label>
<Label Content="{Binding ObjParameter}" FontSize="16" ></Label> </StackPanel>
</StackPanel>
</GroupBox>
</StackPanel> <StackPanel>
<GroupBox Header="事件转命令" BorderBrush="#FF11519C" BorderThickness="1" FontSize="16" Foreground="#FFCDAA0C" Margin="2">
<StackPanel>
<StackPanel>
<ListBox x:Name="lb" ItemsSource="{Binding ListBoxData}" BorderThickness="0" SelectedIndex="{Binding SelectIndex}" >
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<mvvm:EventToCommand Command="{Binding SelectionChangedCommand}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Width="{Binding ActualWidth,RelativeSource={RelativeSource AncestorType={x:Type ListBox}}}"/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel> <ListBox.ItemTemplate>
<DataTemplate>
<Border BorderBrush="AntiqueWhite" BorderThickness="1">
<StackPanel Margin="2"> <Image Source="{Binding Img}" Width="96" Height="96"/>
<TextBlock HorizontalAlignment="Center" Text="{Binding Info}"/> </StackPanel>
</Border>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<Label Content="您选择的是:" FontSize="16" ></Label>
<Label Content="{Binding Path=SelResult,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" FontSize="16" />
</StackPanel>
</StackPanel>
</GroupBox>
</StackPanel> </StackPanel>
</Window>
1 using GalaSoft.MvvmLight;
2
3 namespace MvvmLightDemo1.ViewModel
4 {
5 public class UserModel: ObservableObject
6 {
7 private string userName;
8
9 public string UserName
10 {
11 get { return userName; }
12 set
13 {
14 userName = value;
15 RaisePropertyChanged();
16 }
17 }
18
19 private string passWord;
20
21 public string PassWord
22 {
23 get { return passWord; }
24 set
25 {
26 passWord = value;
27 RaisePropertyChanged();
28 }
29 }
30
31
32 }
33 }
using MvvmLightDemo1.ViewModel;
using System;
using System.Linq;
using System.Windows.Data; namespace MvvmLightDemo1.Converter
{
public class UserInfoConverter: IMultiValueConverter
{
public object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (!values.Cast<string>().Any(text => string.IsNullOrEmpty(text)) && values.Count() == 2)
{
UserModel userModel = new UserModel() { UserName = values[0].ToString(), PassWord = values[1].ToString()};
return userModel;
} return null;
} public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
private RelayCommand<UserModel> addUserCommandWithObjPar; public RelayCommand<UserModel> AddUserCommandWithObjPar
{
get
{
if (addUserCommandWithObjPar == null)
{
addUserCommandWithObjPar = new RelayCommand<UserModel>(AddUserWithObjPar);
}
return addUserCommandWithObjPar;
}
set { addUserCommandWithObjPar = value; }
}
private void AddUserWithObjPar(UserModel par)
{
ObjParameter = "UserName: "+ par.UserName + " Password: " + par.PassWord;
}
后记:
从MVVM的模式来说,其实命令中的参数传递未必是必要的。与其维护一段额外的参数代码,还不如把所有的交互参数细化成为当前DataContext下的全局属性。View开发人员和ViewModel开发人员共同维护好这份命令清单和属性清单即可。
四、EventToCommand
在WPF中,并不是所有控件都有Command,例如TextBox,那么当文本改变,我们需要处理一些逻辑,这些逻辑在ViewModel中,没有Command如何绑定呢?
这个时候我们就用到EventToCommand,事件转命令,可以将一些事件例如TextChanged,Checked等事件转换成命令的方式。
接下来我们就以ListBox为例子,来看看具体的实例:
View代码:(这边声明了i特性和mvvm特性,一个是为了拥有触发器和行为附加属性的能力,当事件触发时,会去调用相应的命令,EventName代表触发的事件名称;一个是为了使用MVVMLight中 EventToCommand功能。)
这边就是当ListBox执行SelectionChanged事件的时候,会相应去执行ViewModel中 SelectionChangedCommand命令。
代码片段如下:
<Window x:Class="MvvmLightDemo1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:MvvmLightDemo1"
xmlns:cvt="clr-namespace:MvvmLightDemo1.Converter"
xmlns:mvvm="http://www.galasoft.ch/mvvmlight"
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
mc:Ignorable="d"
Title="MVVMLIghtDemo1" Height="500" Width="700" >
<Window.Resources>
<cvt:UserInfoConverter x:Key="userInfoConverter"></cvt:UserInfoConverter>
</Window.Resources>
<Window.DataContext>
<Binding Path="Main" Source="{StaticResource Locator}"></Binding>
</Window.DataContext>
<StackPanel>
<StackPanel>
<GroupBox Header="带string类型参数的命令" BorderBrush="#FF11519C" BorderThickness="1" FontSize="16" Foreground="#FFCDAA0C" Margin="2">
<StackPanel>
<StackPanel Orientation="Horizontal">
<Label Content="UserList:" VerticalContentAlignment="Center" FontSize="20" ></Label>
<Label Content="{Binding Path=UserList,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" FontSize="20" />
</StackPanel>
<StackPanel Orientation="Horizontal">
<Label Content="UserName:" VerticalContentAlignment="Center" FontSize="20" ></Label>
<TextBox Width="200" Name="tbUser"></TextBox>
<Button Content="AddUser" Command="{Binding AddUserCommand}" CommandParameter="{Binding ElementName=tbUser,Path=Text}"></Button>
<CheckBox Content="IsCanAdd" VerticalAlignment="Center" FontSize="16" IsChecked="{Binding IsCanAddUser, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"></CheckBox>
</StackPanel>
</StackPanel>
</GroupBox>
</StackPanel> <StackPanel>
<GroupBox Header="带对象类型参数的命令" BorderBrush="#FF11519C" BorderThickness="1" FontSize="16" Foreground="#FF127C0D" Margin="2">
<StackPanel>
<StackPanel Orientation="Horizontal">
<Label Content="UserName:" FontSize="16" ></Label>
<TextBox Width="200" Name="tbxUser" FontSize="16" />
<Label Content="Password:" FontSize="16" ></Label>
<TextBox Width="200" Name="tbxPwd" FontSize="16" />
<Button Content="AddUser" Command="{Binding AddUserCommandWithObjPar}">
<Button.CommandParameter>
<MultiBinding Converter="{StaticResource userInfoConverter}">
<Binding ElementName="tbxUser" Path="Text"/>
<Binding ElementName="tbxPwd" Path="Text"/>
</MultiBinding>
</Button.CommandParameter> </Button>
</StackPanel>
<StackPanel Orientation="Horizontal">
<Label Content="Parameter:" FontSize="16" ></Label>
<Label Content="{Binding ObjParameter}" FontSize="16" ></Label> </StackPanel>
</StackPanel>
</GroupBox>
</StackPanel> <StackPanel>
<GroupBox Header="事件转命令" BorderBrush="#FF11519C" BorderThickness="1" FontSize="16" Foreground="#FFCDAA0C" Margin="2">
<StackPanel>
<StackPanel>
<ListBox x:Name="lb" ItemsSource="{Binding ListBoxData}" BorderThickness="0" SelectedIndex="{Binding SelectIndex}" >
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<mvvm:EventToCommand Command="{Binding SelectionChangedCommand}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel Width="{Binding ActualWidth,RelativeSource={RelativeSource AncestorType={x:Type ListBox}}}"/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel> <ListBox.ItemTemplate>
<DataTemplate>
<Border BorderBrush="AntiqueWhite" BorderThickness="1">
<StackPanel Margin="2"> <Image Source="{Binding Img}" Width="96" Height="96"/>
<TextBlock HorizontalAlignment="Center" Text="{Binding Info}"/> </StackPanel>
</Border>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<Label Content="您选择的是:" FontSize="16" ></Label>
<Label Content="{Binding Path=SelResult,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" FontSize="16" />
</StackPanel>
</StackPanel>
</GroupBox>
</StackPanel> </StackPanel>
</Window>
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.CommandWpf;
using MvvmLightDemo1.Model;
using System.Collections;
using System.Collections.ObjectModel;
using System.Windows.Input; namespace MvvmLightDemo1.ViewModel
{
public class MainViewModel : ViewModelBase
{
private WelcomeModel welcomeModel;
public WelcomeModel WelcomeModel
{
get { return welcomeModel; }
set { welcomeModel = value; RaisePropertyChanged(() => WelcomeModel); }
} private string objParameter = ""; public string ObjParameter
{
get { return objParameter; }
set
{
objParameter = value;
RaisePropertyChanged();
}
} private int selectIndex = -1; public int SelectIndex
{
get { return selectIndex; }
set
{
selectIndex = value;
RaisePropertyChanged();
}
}
private string selResult = ""; public string SelResult
{
get { return selResult; }
set
{
selResult = value;
RaisePropertyChanged();
}
}
private IEnumerable listBoxData = new ObservableCollection<DataModel>()
{
new DataModel(){ Img="/MvvmLightDemo1;component/Img/1.png",Info=" Honey Peach " },
new DataModel(){ Img="/MvvmLightDemo1;component/Img/2.png",Info="Tomato" },
new DataModel(){ Img="/MvvmLightDemo1;component/Img/3.png",Info="Banana" },
new DataModel(){ Img="/MvvmLightDemo1;component/Img/4.png",Info="Chilli " },
new DataModel(){ Img="/MvvmLightDemo1;component/Img/5.png",Info="Apple" },
};
/// <summary>
/// LisBox数据模板
/// </summary>
public IEnumerable ListBoxData
{
get { return listBoxData; }
set { listBoxData = value; RaisePropertyChanged(() => ListBoxData); }
}
/// <summary>
/// Initializes a new instance of the MainViewModel class.
/// </summary>
public MainViewModel()
{
WelcomeModel = new WelcomeModel() { WelcomeMsg = "Welcome to MVVMLight World!" };
} private string userList = "Mary"; public string UserList
{
get { return userList; }
set
{
userList = value;
RaisePropertyChanged();
}
}
private string user = ""; public string User
{
get { return user; }
set { user = value; }
}
private bool isCanAddUser = true; public bool IsCanAddUser
{
get { return isCanAddUser; }
set { isCanAddUser = value; }
} #region Command
private RelayCommand<string> addUserCommand; public RelayCommand<string> AddUserCommand
{
get
{
if (addUserCommand == null)
{
addUserCommand = new RelayCommand<string>(AddUser, (string p) => { return IsCanAddUser; });
}
return addUserCommand;
}
set { addUserCommand = value; }
}
private void AddUser(string par)
{
UserList = UserList + " " + par;
} private RelayCommand<UserModel> addUserCommandWithObjPar; public RelayCommand<UserModel> AddUserCommandWithObjPar
{
get
{
if (addUserCommandWithObjPar == null)
{
addUserCommandWithObjPar = new RelayCommand<UserModel>(AddUserWithObjPar);
}
return addUserCommandWithObjPar;
}
set { addUserCommandWithObjPar = value; }
}
private void AddUserWithObjPar(UserModel par)
{
ObjParameter = "UserName: "+ par.UserName + " Password: " + par.PassWord;
} private RelayCommand selectionChangedCommand; public RelayCommand SelectionChangedCommand
{
get
{
if (selectionChangedCommand == null)
{
selectionChangedCommand = new RelayCommand(SelectChange);
}
return selectionChangedCommand;
}
set { selectionChangedCommand = value; }
}
private void SelectChange()
{
int i = 0;
foreach(var a in ListBoxData)
{
if(i == SelectIndex)
{
SelResult = (a as DataModel).Info;
break;
}
i++;
}
}
#endregion }
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks; namespace MvvmLightDemo1.Model
{
public class DataModel
{
private string img; public string Img
{
get { return img; }
set { img = value; }
} private string info; public string Info
{
get { return info; }
set { info = value; }
}
}
}
运行结果如下:
五、带原事件参数的命令绑定
代码片段如下:
<StackPanel>
<GroupBox Header="带事件参数的命令" BorderBrush="#FF11519C" BorderThickness="1" FontSize="16" Foreground="#FF127C0D" Margin="2"> <StackPanel Orientation="Horizontal">
<Button Content="拖拽上传文件" AllowDrop="True">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Drop">
<mvvm:EventToCommand PassEventArgsToCommand="True" Command="{Binding DropCommand}" />
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
<Label Content="FilePath:" FontSize="16" ></Label>
<Label Content="{Binding DraggedFilePath}" FontSize="16" ></Label> </StackPanel> </GroupBox>
</StackPanel>
private RelayCommand<DragEventArgs> dropCommand;
/// <summary>
/// 传递原事件参数
/// </summary>
public RelayCommand<DragEventArgs> DropCommand
{
get
{
if (dropCommand == null)
dropCommand = new RelayCommand<DragEventArgs>(e => ExecuteDrop(e));
return dropCommand;
}
set { dropCommand = value; }
} private void ExecuteDrop(DragEventArgs e)
{
DraggedFilePath = ((System.Array)e.Data.GetData(System.Windows.DataFormats.FileDrop)).GetValue(0).ToString();
}
注:本系列文章参考
https://www.cnblogs.com/wzh2010/p/6607702.html
MVVMLight学习笔记(五)---RelayCommand深究的更多相关文章
- C#可扩展编程之MEF学习笔记(五):MEF高级进阶
好久没有写博客了,今天抽空继续写MEF系列的文章.有园友提出这种系列的文章要做个目录,看起来方便,所以就抽空做了一个,放到每篇文章的最后. 前面四篇讲了MEF的基础知识,学完了前四篇,MEF中比较常用 ...
- (转)Qt Model/View 学习笔记 (五)——View 类
Qt Model/View 学习笔记 (五) View 类 概念 在model/view架构中,view从model中获得数据项然后显示给用户.数据显示的方式不必与model提供的表示方式相同,可以与 ...
- java之jvm学习笔记五(实践写自己的类装载器)
java之jvm学习笔记五(实践写自己的类装载器) 课程源码:http://download.csdn.net/detail/yfqnihao/4866501 前面第三和第四节我们一直在强调一句话,类 ...
- Learning ROS for Robotics Programming Second Edition学习笔记(五) indigo computer vision
中文译著已经出版,详情请参考:http://blog.csdn.net/ZhangRelay/article/category/6506865 Learning ROS for Robotics Pr ...
- Typescript 学习笔记五:类
中文网:https://www.tslang.cn/ 官网:http://www.typescriptlang.org/ 目录: Typescript 学习笔记一:介绍.安装.编译 Typescrip ...
- ES6学习笔记<五> Module的操作——import、export、as
import export 这两个家伙对应的就是es6自己的 module功能. 我们之前写的Javascript一直都没有模块化的体系,无法将一个庞大的js工程拆分成一个个功能相对独立但相互依赖的小 ...
- muduo网络库学习笔记(五) 链接器Connector与监听器Acceptor
目录 muduo网络库学习笔记(五) 链接器Connector与监听器Acceptor Connector 系统函数connect 处理非阻塞connect的步骤: Connetor时序图 Accep ...
- python3.4学习笔记(五) IDLE显示行号问题,插件安装和其他开发工具介绍
python3.4学习笔记(五) IDLE显示行号问题,插件安装和其他开发工具介绍 IDLE默认不能显示行号,使用ALT+G 跳到对应行号,在右下角有显示光标所在行.列.pycharm免费社区版.Su ...
- Go语言学习笔记五: 条件语句
Go语言学习笔记五: 条件语句 if语句 if 布尔表达式 { /* 在布尔表达式为 true 时执行 */ } 竟然没有括号,和python很像.但是有大括号,与python又不一样. 例子: pa ...
- 【opencv学习笔记五】一个简单程序:图像读取与显示
今天我们来学习一个最简单的程序,即从文件读取图像并且创建窗口显示该图像. 目录 [imread]图像读取 [namedWindow]创建window窗口 [imshow]图像显示 [imwrite]图 ...
随机推荐
- WIN7 32运行提示无法定位api-ms-win-crt-heap-l1-1-0.dll解决方法
WIN7 32位无法运行adbapi-ms-win-crt-heap-l1-1-0.dll运行ADB ,提示无法定位api-ms-win-crt-heap-l1-1-0.dll需要安装https:// ...
- 从代码生成说起,带你深入理解 mybatis generator 源码
枯燥的任务 这一切都要从多年前说起. 那时候刚入职一家新公司,项目经理给我分配了一个比较简单的工作,为所有的数据库字段整理一张元数据表. 因为很多接手的项目文档都不全,所以需要统一整理一份基本的字典表 ...
- 手写一个超简单的Vue
基本结构 这里我根据自己的理解模仿了Vue的单文件写法,通过给Vue.createApp传入参数再挂载元素来实现页面与数据的互动. 其中理解不免有错,希望大佬轻喷. 收集数据 这里将Vue.creat ...
- Windows API 简介
操作系统的作用之一就是屏蔽一些复杂的直接对硬件操作,并提供给用户一个简单明确的应用接口,类外对于一些基本的或常用的操作也以API的形式提供给用户,比如内存管理.文件管理等. 消息传递机制 消息循环是一 ...
- tomcat与springmvc 结合 之---第19篇 springmvc 加载.xml文件的bean 过程
writedby 张艳涛,看springmvc 的源码太难了,怎么办, 这篇文章主要分析了看透springmvc的第9章结尾的 如何解析xml 命名空间标签 <?xml version=&quo ...
- C#曲线分析平台的制作(一,ajax+json前后台数据传递)
在最近的项目学习中,需要建立一个实时数据的曲线分析平台,这其中的关键在于前后台数据传递过程的学习,经过一天的前辈资料整理,大概有了一定的思路,现总结如下: 1.利用jquery下ajax函数实现: & ...
- Discuz 7.x/6.x 全局变量防御绕过导致代码执行
地址 http://192.168.49.2:8080/viewthread.php?tid=13&extra=page%3D1 安装成功后,找一个已存在的帖子,向其发送数据包,并在Cooki ...
- 配置 Nvidia GPU 主机的运行环境
在 Linux 主机上配置了很多次 Cuda/CuDNN 的运行环境,在此记录下用到的脚本命令以复用. 特别提醒,先了解清楚 GPU 卡的型号,查清与主机 Linux 内核兼容的驱动程序.Cuda 和 ...
- Java互联网架构师系统进阶课程学习 (4)【享学】
Java互联网架构师系统进阶课程学习 (4)[享学] 4.显式锁和AQS 显式锁 Lock接口和核心方法 Lock接口和synchronized的比较 synchronized 代码简洁,Lock ...
- Android ELF文件解析
0X01 ELF初认识 elf文件是linux下的二进制文件,相当于windows下的PE文件,Android系统里的dll. 解析elf文件两个用处:1.so加固:2.frida(xposed)检 ...