View与Controller的连接
来源:互联网 发布:pic单片机重启 编辑:程序博客网 时间:2024/06/06 05:22
从View向Controller传值
<html><body><form action="{{url('/R_construct')}}" method="get">/*对应get方法,R_Controller路由*/ 你的链表<br/> <input type="text" name="list">//要传到Controller里的变量名为list <input type="submit" value="Submit"></form></body></html> public function R_construct(Request $request){ $str = $request->input('list');//从View中接受list变量并存入$str $list = explode(" ", $str); $size = count($list); for($i = 1; $i <= $size; $i++) { DB::table('LinkedList') ->insert( ['id' => $i, 'name' => $list[$i-1]] ); } return view('construct_success');//返回construct_success.blade.php页面}
Controller向View传值
传参数
public function size(){ $count = DB::table('LinkedList') ->count(); return view('size_success', ['size' => $count]);/*将$count的值存入size传到size_success.blade.php*/}<html><body><h1>链表长度为{{$size}}</h1><br>//用{{$size}}接收参数<div class="links"><a href={{ url('/') }}>首页</a></div></body></html>
传数据库值或传类
public function print_list(){ $print = DB::table('LinkedList')->get(); return view('print_success', ['print' => $print]);}<html><body><h1>链表为</h1>@forelse($print as $prints)//用forelse或foreach等方法便历 <h3>{{$prints->name}}</h3>@empty <h3>空</h3>@endforelse <div class="links"> <a href={{ url('/') }}>首页</a> </div></body></html>
0 0
- View与Controller的连接
- 3.Controller与View
- View Controller的生命周期
- View Controller 的生命周期
- 获取view的controller
- View Controller的生命周期
- 更轻量的View Controller
- .net MVC的controller与view的传值方式
- MVC中Controller与View之间的数据传递
- 1 Spring MVC View层与Controller层的衔接
- Asp.net mvc Controller与 View之间的传递
- <context:include-filter> 与 mvc:view-controller 的使用
- [View] -- View与Controller和Widget交互
- Collection View Controller的使用
- <mvc:view-controller />的用法
- view controller的automaticallyAdjustsScrollViewInsets属性
- UI view controller的生命周期
- View - Controller 的通信模式
- 十大经典排序算法js实现
- keras.model的保存与打开
- 局部刷新
- jsp图片显示问题(绝对路径和相对路径)
- c语言函数strstr分析
- View与Controller的连接
- 项目二----项目的开始是人生的阶梯【哈哈】
- jenkins 构建触发器 区别
- Lua自己实现载入一个模块
- 选择除id以外的全部元素
- shell变量字符串常用操作小结
- 机器学习----贝叶斯分类器(贝叶斯网络)
- Win7 中安装 Composer (PHP)
- Linux上iptables防火墙的基本应用教程