在做项目中,我们一直使用的是V(View)层和C(Controllers)层,视图的加载,数据的传递,一直都是View和Controller在交互,那么 M(Model)层的意义到底在哪???(我们新建一个MVC3.0应用程序)
public class ChangePasswordModel
{
[Required]
[DataType(DataType.Password)]
[Display(Name = "当前密码")]
public string OldPassword { get; set; }
[Required]
[StringLength(100, ErrorMessage ="{0} 必须至少包含 {2} 个字符。", MinimumLength = 6)]
[DataType(DataType.Password)]
[Display(Name = "新密码")]
public string NewPassword { get; set; }
[DataType(DataType.Password)]
[Display(Name = "确认新密码")]
[System.Web.Mvc.Compare("NewPassword", ErrorMessage ="新密码和确认密码不匹配。")]
public string ConfirmPassword { get;set; }
}
@using(Html.BeginForm()) {
@Html.ValidationSummary(true,"密码更改不成功。请更正错误并重试。")
@Html.PasswordFor(m =>m.OldPassword)
@Html.ValidationMessageFor(m=> m.OldPassword)
@Html.LabelFor(m =>m.NewPassword)
@Html.PasswordFor(m =>m.NewPassword)
@Html.ValidationMessageFor(m=> m.NewPassword)
@Html.LabelFor(m =>m.ConfirmPassword)
@Html.PasswordFor(m =>m.ConfirmPassword)
@Html.ValidationMessageFor(m=> m.ConfirmPassword)
}
model层也有一些逻辑判断的内容,所以MVC的逻辑关系分的并不是特别清晰。
一点点小见解!!