尊龙凯时人生就是博

laravelÔõÑùʵÏÖÌøתҳÃæ´ø²ÎÊýµÄ¹¦Ð§

ÔÚlaravel¿ò¼ÜÖУ¬ÌøתҳÃæÊǷǾ­³£¼ûµÄ²Ù×÷¡£ÓÐʱ¼äÐèÒªÔÚÌøתʱ´øһЩ²ÎÊý£¬ºÃ±ÈËÑË÷Òªº¦´Ê¡¢·ÖÒ³ÊýµÈµÈ¡£Õâʱ¼ä¾ÍÐèҪʵÏÖÌøתҳÃæ´ø²ÎÊýµÄ¹¦Ð§¡£±¾ÎĽ«ÏÈÈÝÔõÑùʵÏÖÌøתҳÃæ´ø²ÎÊýµÄ¹¦Ð§£¬ÊµÏÖÎÞÖض¨Ïò´«²Î¡£

1¡¢»ù±¾Ìøת

ÔÚLaravel¿ò¼ÜÖУ¬ÌøתÓÐÁ½ÖÖ·½·¨£¬Ò»ÖÖÊÇʹÓÃredirectº¯Êý£¬ÁíÒ»ÖÖÊÇʹÓÃviewº¯Êý¡£redirectº¯ÊýÓÃÓÚÌøתµ½ÆäËû¿ØÖÆÆ÷µÄÒªÁ죬viewº¯ÊýÓÃÓÚÌøתµ½ÊÓͼÎļþ¡£

ʹÓÃredirectº¯Êý£¬¿ÉÒÔÕâÑùд£º

return redirect()->action(
    '[¿ØÖÆÆ÷Ãû³Æ]@[ÒªÁìÃû³Æ]'
);

µÇ¼ºó¸´ÖÆ

ʹÓÃviewº¯Êý£¬¿ÉÒÔÕâÑùд£º

return view('[ÊÓͼÎļþ·¾¶]', [²ÎÊýÊý×é]);

µÇ¼ºó¸´ÖÆ

ÕâÁ½ÖÖ·½·¨¶¼Ã»ÓÐת´ï²ÎÊý£¬ÈôÊÇÐèҪת´ï²ÎÊý£¬ÎÒÃÇÐèÒª½ÓÄÉÒÔÏÂÒªÁì¡£

2¡¢´ø²ÎÊýÌøת

2.1¡¢Ê¹ÓÃÖÐÐļþ

LaravelÌṩÁ˺ÜÊÇÀû±ãµÄÖÐÐļþ¹¦Ð§£¬ÎÒÃÇ¿ÉÒÔʹÓÃÖÐÐļþ½«²ÎÊýת´ïµ½ÏÂÒ»¸öÇëÇóÖС£

ÎÒÃÇ¿ÉÒÔн¨Ò»ÆäÖÐÐļþ£¬ÔÚÖÐÐļþÖн«²ÎÊýÉúÑÄÆðÀ´£¬È»ºóÔÚÏÂÒ»¸öÇëÇóÖÐÈ¡³öÕâЩ²ÎÊý¡£ÖÐÐļþ´úÂëÈçÏ£º

<?php namespace App\Http\Middleware;

use Closure;

class ParamsMiddleware
{
    public function handle($request, Closure $next)
    {
        $params = [
            'param1' => 'value1',
            'param2' =&gt; 'value2',
            'param3' =&gt; 'value3',
        ];
        
        $request-&gt;session()-&gt;put('params', $params);
        
        return $next($request);
    }
}

µÇ¼ºó¸´ÖÆ

½«²ÎÊýÉúÑÄÔÚsessionÖУ¬È»ºóÔÚÏÂÒ»¸öÇëÇóÖÐÈ¡³öÀ´¡£

$params = $request-&gt;session()-&gt;get('params');

µÇ¼ºó¸´ÖÆ

ÎÒÃÇ¿ÉÒÔÔÚweb.phpÎļþÖÐ×¢²áÖÐÐļþ£¬²¢½«ÖÐÐļþÌí¼Óµ½Â·ÓÉÖС£

Route::middleware('params')-&gt;get('/', '[¿ØÖÆÆ÷Ãû³Æ]@[ÒªÁìÃû³Æ]');

µÇ¼ºó¸´ÖÆ

ÕâÖÖ·½·¨µÄÈõµãÊÇÐèҪʹÓÃsession£¬ÈôÊÇûÓпªÆôsession£¬ÔòÎÞ·¨Ê¹Óá£

2.2¡¢Ê¹ÓÃURL²ÎÊý

ÎÒÃÇ»¹¿ÉÒÔʹÓÃURL²ÎÊý½«²ÎÊýת´ïµ½ÏÂÒ»¸öÒ³ÃæÖС£

ÔÚÌøתʱ£¬ÎÒÃÇ¿ÉÒÔʹÓÃrouteº¯ÊýÖ¸¶¨Â·ÓÉ£¬È»ºóÔÚ·ÓÉÖÐÉèÖòÎÊý¡£

Ìøת´úÂ룺

return redirect()-&gt;route('[·ÓÉÃû³Æ]', ['param1' =&gt; 'value1', 'param2' =&gt; 'value2']);

µÇ¼ºó¸´ÖÆ

·ÓÉ´úÂ룺

Route::get('/', '[¿ØÖÆÆ÷Ãû³Æ]@[ÒªÁìÃû³Æ]')-&gt;name('[·ÓÉÃû³Æ]');

µÇ¼ºó¸´ÖÆ

ÔÚ¿ØÖÆÆ÷ÖУ¬ÎÒÃÇ¿ÉÒÔʹÓÃrequest¹¤¾ß»ñÈ¡URL²ÎÊý¡£

$request-&gt;input('param1');

µÇ¼ºó¸´ÖÆ

ÕâÖÖ·½·¨µÄÈõµãÊÇURL²ÎÊý»áÏÔʾÔÚURLµØµãÀ¸ÖУ¬¿ÉÄÜ»á¶ÔÓû§Ôì³ÉÒ»¶¨µÄÀ§ÈÅ¡£

2.3¡¢Ê¹ÓÃÖض¨Ïò²ÎÊý

LaravelÌṩÁËÁíÒ»ÖÖÒªÁ죬¿ÉÒÔʵÏÖÎÞÖض¨Ïò´«²Î¡£ÎÒÃÇÏÈ¿´´úÂ룬ȻºóÔÚÚ¹ÊÍ¡£

return redirect()-&gt;to('/')-&gt;with('param1', 'value1')-&gt;with('param2', 'value2');

µÇ¼ºó¸´ÖÆ

ÔÚÖض¨Ïòʱ£¬ÎÒÃÇ¿ÉÒÔʹÓÃwithº¯Êý½«²ÎÊýÉúÑÄÔÚsessionÖС£ÕâÑù£¬²ÎÊý¾Í¿ÉÒÔÔÚÏÂÒ»¸öÇëÇóÖÐʹÓÃÁË¡£

ÔÚ¿ØÖÆÆ÷ÖУ¬ÎÒÃÇ¿ÉÒÔÕâÑù»ñÈ¡²ÎÊý¡£

$request-&gt;session()-&gt;get('param1');
$request-&gt;session()-&gt;get('param2');

µÇ¼ºó¸´ÖÆ

ÕâÖÖ·½·¨ÊµÏÖÁËÎÞÖض¨Ïò´«²Î£¬Í¬Ê±Ò²×èÖ¹ÁËURL²ÎÊý¶ÔÓû§µÄ×ÌÈÅ¡£

×ܽá

ÔÚLaravelÖУ¬ÊµÏÖÌøתҳÃæ´ø²ÎÊýµÄ¹¦Ð§ÓжàÖÖÒªÁì¡ £¿ÉÒÔʹÓÃÖÐÐļþ¡¢URL²ÎÊý»òÕßÖض¨Ïò²ÎÊý¡£²î±ðµÄÒªÁìÓвî±ðµÄÓÅÈõµã£¬ÎÒÃÇÐèҪƾ֤ÏÖʵÐèÇóÑ¡Ôñ×îºÏÊʵÄÒªÁì¡£

ÒÔÉϾÍÊÇlaravelÔõÑùʵÏÖÌøתҳÃæ´ø²ÎÊýµÄ¹¦Ð§µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí£¬°æȨÕùÒéÓë±¾Õ¾Î޹أ¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í尊龙凯时人生就是博ÂËÓÍ»úÍø¹Ù·½Ì¬¶È£¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ£¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢£¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢£¬ÇëÄúÁ¬Ã¦ÁªÏµ尊龙凯时人生就是博ʵʱÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ尊龙凯时人生就是博

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎ壬9:30-18:30£¬½ÚãåÈÕÐÝÏ¢

QR code
sitemap¡¢ÍøÕ¾µØͼ