沃梦达 / 编程问答 / php问题 / 正文

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

本文标题为:laravel 表单发布问题

基础教程推荐