laravel form post issue(laravel 表单发布问题)
问题描述
我正在使用 Laravel
框架构建一个练习应用程序我在其中一个视图中构建了一个表单,该表单设置为 post 到同一视图本身,但是当我点击提交表单已发布但我没有得到所需的输出,我再次看到原始视图.
I am building a practice app with the Laravel
framework I built a form in one of the views which is set to post to the same view itself but when I hit submit the form is posted however I do not get the desired output, I see the original view again.
这是我的看法index.blade.php
@extends('master')
@section('container')
<div class="wrapper">
{{ Form::open(array('url' => '/', 'method' => 'post')) }}
{{ Form::text('url') }}
{{ Form::text('valid') }}
{{ Form::submit('shorten') }}
{{ Form::close() }}
</div><!-- /wrapper -->
@stop
和我的 routes.php
Route::get('/', function()
{
return View::make('index');
});
Route::post('/', function()
{
return 'successfull';
});
到目前为止我已经尝试过什么
What I've tried so far
我尝试将帖子更改为不同的视图,并且成功了.但是我希望表单发布到同一个视图本身.
I tried changing the post to a different view and it worked. However I want the form to post to the same view itself.
我没有返回一个字符串,而是试图返回一个视图没用.
Instead of returning a string I tried to return make a view still it didn't work.
我做错了什么?
我看到当表单发出发布请求时,我收到了 301 MOVED PERMANENTLY HEADER
I see that when the form is making the post request I am getting a 301 MOVED PERMANENTLY HEADER
推荐答案
{{ Form::open(array('url' => ' ', 'method' => 'post')) }}
传递一个空格作为 url 对我有用.
Passing a space as the url has worked for me.
这篇关于laravel 表单发布问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:laravel 表单发布问题
- Laravel 仓库 2022-01-01
- PHP Count 布尔数组中真值的数量 2021-01-01
- 正确分离 PHP 中的逻辑/样式 2021-01-01
- Oracle 即时客户端 DYLD_LIBRARY_PATH 错误 2022-01-01
- Mod使用GET变量将子域重写为PHP 2021-01-01
- 如何定位 php.ini 文件 (xampp) 2022-01-01
- 从 PHP 中的输入表单获取日期 2022-01-01
- SoapClient 设置自定义 HTTP Header 2021-01-01
- 带有通配符的 Laravel 验证器 2021-01-01
- 没有作曲家的 PSR4 自动加载 2022-01-01