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 表单发布问题
基础教程推荐
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
- 如何替换eregi() 2022-01-01
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
- PHP 类:全局变量作为类中的属性 2021-01-01
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
- 在PHP中根据W3C规范Unicode 2022-01-01
- 如何在 Laravel 中使用 React Router? 2022-01-01
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
