javascript
spring.web.mvc 注入(控制器属性注入) -凯发ag旗舰厅登录网址下载
1.web.config配置
connectionstring="data source=.\sqlexpress;integrated security=sspi;attachdbfilename=|datadirectory|aspnetdb.mdf;user instance=true"
providername="system.data.sqlclient" />
warninglevel="4" compileroptions="/langversion:6 /nowarn:1659;1699;1701"/>
warninglevel="4" compileroptions="/langversion:14 /nowarn:41008 /define:_mytype=\"web\" /optioninfer "/>
2.根目录添加lib文件夹(spring.core spring.web.mvc common.logging.dll common.logging.log4net.dll)
程序集引用添加这4个东西
3.mvcapplication 注册路由重写 继承springmvcapplication
using system;
using system.collections.generic;
using system.linq;
using system.web;
using system.web.mvc;
using system.web.routing;
using spring.web.mvc;
namespace webapplication12
{
public class mvcapplication :springmvcapplication
{
protected override void registerroutes(routecollection routes)
{
routes.ignoreroute("{resource}.axd/{*pathinfo}");
routes.maproute(
name: "default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "home", action = "index", id = urlparameter.optional }
);
}
//protected void application_start()
//{
// arearegistration.registerallareas();
// routeconfig.registerroutes(routetable.routes);
//}
}
}
3.根目录下新建config文件夹 里面添加controllers.xml(右键属性 始终复制 我的迷信)
4.控制器添加message属性之后用于注入
using system;
using system.collections.generic;
using system.linq;
using system.web;
using system.web.mvc;
namespace webapplication12.controllers
{
public class homecontroller : controller
{
public string message { get; set; }
// get: home
public actionresult index()
{
viewdata["message"] = message;
return view();
}
}
}
4.视图调用
@{
layout = null;
}
转载于:https://www.cnblogs.com/kexb/p/4823236.html
总结
以上是凯发ag旗舰厅登录网址下载为你收集整理的spring.web.mvc 注入(控制器属性注入)的全部内容,希望文章能够帮你解决所遇到的问题。
如果觉得凯发ag旗舰厅登录网址下载网站内容还不错,欢迎将凯发ag旗舰厅登录网址下载推荐给好友。
- 上一篇: angularjs学习笔记
- 下一篇: mkyaffs2image编译