laravel 表单发布问题

laravel form post issue(laravel 表单发布问题)
本文介绍了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 表单发布问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Convert JSON integers and floats to strings(将JSON整数和浮点数转换为字符串)
in php how do I use preg replace to turn a url into a tinyurl(在php中,如何使用preg替换将URL转换为TinyURL)
all day appointment for ics calendar file wont work(ICS日历文件的全天约会不起作用)
trim function is giving unexpected values php(Trim函数提供了意外的值php)
Basic PDO connection to MySQL(到MySQL的基本PDO连接)
PHP number_format returns 1.00(Php number_Format返回1.00)