在laravel 7中获取本地文件时发现页面未找到错误。

问题描述 投票:0回答:1

我想获取本地产品描述文件,在产品页面,当锥子点击阅读更多选项获取完整的产品描述时,显示错误404页面未找到。

本地产品文件路径是resourcesviewshtmlproductschili.blade.php,这里的产品是辣椒。

<div class="col-md-4 services-grid">
                     <div class="history-grid-image">
                        <img src="images/Chilli Farm.jpg" class="img-responsive" alt="">
                     </div>
                     <div class="services-info">
                        <h4>Chili</h4>
                        <p>The Chili pepper is the fruit of plants from the genus capsicum which are members of nightshade family Solanaceae. 
                        <!-- Chili is extremely popular in India as it brings heat to the food. -->
                        <!-- India having a rich history of spices and mostly chili finds a place in every dish of Indian food.<br> -->
                        <!-- Medicinal properties: Capsaicin is the chemical used in plain reliever ointment.
                        Capsaicin also used in pepper spray and tear gas as chemical irritants to control the crowd in an emergency situation. -->
                        <!-- Rich in :  vitamin B6, vitamin A, iron, copper, potassium and a small amount of protein and carbohydrates.<br> -->
                        <!-- Helps in digestion, Weight loss, No Cholesterol Content. -->
                        <!-- Good for Diabetic people. -->
                        <!-- Fact : Chili was first introduced to India by the Portuguese towards the end of the century.</p> -->
                        <a class="more" href="{{ url('products-chili') }}"> Read More</a>
                     </div>
                  </div>

这里是产品描述文件

@extends("layouts.html")

@section("title", "Chili|GreenGoodsExports")

@section("chili")

<!DOCTYPE html>
<html>
<head>

</head>
<body>

<!--banner-->
    <div class="banner-1">

    </div>  
<!--//banner-->
<!--single-page-->
<div class="single">
    <div class="container">
        <h2 class="tittle-one">Chili</h2>
                <div class="single-page-artical">
                    <div class="artical-content">
                        <h4>Chili</h4>
                        <img class="img-responsive" src="images/Chilli Farm.jpg" alt=" " style="visibility: visible; animation-delay: 0.5s; animation-name: zoomIn;">
                        <p>The Chili pepper is the fruit of plants from the genus capsicum which are members of nightshade family Solanaceae. 
                        Chili is extremely popular in India as it brings heat to the food.
                        India having a rich history of spices and mostly chili finds a place in every dish of Indian food.<br>
                        Medicinal properties: Capsaicin is the chemical used in plain reliever ointment.
                        Capsaicin also used in pepper spray and tear gas as chemical irritants to control the crowd in an emergency situation.
                        Rich in :  vitamin B6, vitamin A, iron, copper, potassium and a small amount of protein and carbohydrates.<br>
                        Helps in digestion, Weight loss, No Cholesterol Content.
                        Good for Diabetic people.
                        Fact : Chili was first introduced to India by the Portuguese towards the end of the century.</p>
                    </div>
                    <div class="artical-links">
                        <ul>
                            <li><i class="glyphicon glyphicon-calendar" aria-hidden="true"></i><span>March 10, 2016</span></li>
                            <li><a href="#"><i class="glyphicon glyphicon-user" aria-hidden="true"></i><span>admin</span></a></li>
                            <li><a href="#"><i class="glyphicon glyphicon-envelope" aria-hidden="true"></i><span>No comments</span></a></li>
                            <li><a href="#"><i class="glyphicon glyphicon-share" aria-hidden="true"></i><span>View posts</span></a></li>

                        </ul>
                    </div>
                    <div class="comment-grid-top">
                        <h3>Responses</h3>
                        <div class="comments-top-top">
                            <div class="top-comment-left">
                                <a href="#"><img class="img-responsive" src="images/co.png" alt=""></a>
                            </div>
                            <div class="top-comment-right">
                                <ul>
                                    <li><span class="left-at"><a href="#">Admin</a></span></li>
                                    <li><span class="right-at">March 10, 2016 at 10.30am</span></li>
                                    <li><a class="reply" href="#">Reply</a></li>
                                </ul>
                            <p>It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout.The point of using Lorem Ipsum is that it has a more-or-less </p>
                            </div>
                            <div class="clearfix"> </div>
                        </div>
                        <div class="comments-top-top top-grid-comment">
                            <div class="top-comment-left">
                                <a href="#"><img class="img-responsive" src="images/co.png" alt=""></a>
                            </div>
                            <div class="top-comment-right">
                                <ul>
                                    <li><span class="left-at"><a href="#">Admin</a></span></li>
                                    <li><span class="right-at">March 18, 2016 at 10.30am</span></li>
                                    <li><a class="reply" href="#">Reply</a></li>
                                </ul>
                            <p>It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout.The point of using Lorem Ipsum is that it has a more-or-less </p>
                            </div>
                            <div class="clearfix"> </div>
                        </div>
                    </div>          
                    <div class="artical-commentbox">
                        <h3>leave a comment</h3>
                        <div class="table-form">
                            <form>
                                <input placeholder="Name" type="text" required="">
                                <input placeholder="Email" type="email" required="">    
                                <input placeholder="Phone" type="text" required="">                                 
                                <textarea placeholder="Message"></textarea>
                                <input type="submit" value="Send">
                            </form>
                        </div>
                    </div>  
                </div>
            </div>
        </div>
    <!--single-page-->

</body>
</html>



@endsection

这里是web.php代码

Route::get("/products/chili", "ProductsController@chili")->name('products-chili');

下面是ProductsController.php的代码。

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class ProductsController extends Controller
{
    public function chili() {
        return view("html.products1.chili");
}

请帮我解决,谢谢...

php html laravel web web-development-server
1个回答
0
投票

在你的返回视图中是不是应该是

 return view("html.products.chili");

而不是

return view("html.products1.chili");

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class ProductsController extends Controller
{
    public function chili() {
        return view("html.products.chili");
    }
}

0
投票

对于 @extends('layouts.html') 要想奏效,必须有 产量('辣椒') 中,这将产生您的 html.blade.php 中 "chili "部分的内容。辣妹子.php NB: html.blade.php包含了所有需要的CSS和JS文件,如下所示。html.blade.php

<!DOCTYPE html>
<html>
<head>
    <!--include-all-your-head-contents-including-meta-tags-css-links-and-js-->
    @yield('title')
</head>
<body>
    @yield('chili')
    <!--include-all-your-scripts-required-->
</body>
</html>

对于您的 辣妹子.php

@extends('layouts.html')
@section("title", "Chili|GreenGoodsExports")

@section("chili")
<!--banner-->
    <div class="banner-1">
    </div>  
<!--//banner-->
<!--single-page-->
<div class="single">
    <div class="container">
        <h2 class="tittle-one">Chili</h2>
                <div class="single-page-artical">
                    <div class="artical-content">
                        <h4>Chili</h4>
                        <img class="img-responsive" src="images/Chilli Farm.jpg" alt=" " style="visibility: visible; animation-delay: 0.5s; animation-name: zoomIn;">
                        <p>The Chili pepper is the fruit of plants from the genus capsicum which are members of nightshade family Solanaceae. 
                        Chili is extremely popular in India as it brings heat to the food.
                        India having a rich history of spices and mostly chili finds a place in every dish of Indian food.<br>
                        Medicinal properties: Capsaicin is the chemical used in plain reliever ointment.
                        Capsaicin also used in pepper spray and tear gas as chemical irritants to control the crowd in an emergency situation.
                        Rich in :  vitamin B6, vitamin A, iron, copper, potassium and a small amount of protein and carbohydrates.<br>
                        Helps in digestion, Weight loss, No Cholesterol Content.
                        Good for Diabetic people.
                        Fact : Chili was first introduced to India by the Portuguese towards the end of the century.</p>
                    </div>
                    <div class="artical-links">
                        <ul>
                            <li><i class="glyphicon glyphicon-calendar" aria-hidden="true"></i><span>March 10, 2016</span></li>
                            <li><a href="#"><i class="glyphicon glyphicon-user" aria-hidden="true"></i><span>admin</span></a></li>
                            <li><a href="#"><i class="glyphicon glyphicon-envelope" aria-hidden="true"></i><span>No comments</span></a></li>
                            <li><a href="#"><i class="glyphicon glyphicon-share" aria-hidden="true"></i><span>View posts</span></a></li>

                        </ul>
                    </div>
                    <div class="comment-grid-top">
                        <h3>Responses</h3>
                        <div class="comments-top-top">
                            <div class="top-comment-left">
                                <a href="#"><img class="img-responsive" src="images/co.png" alt=""></a>
                            </div>
                            <div class="top-comment-right">
                                <ul>
                                    <li><span class="left-at"><a href="#">Admin</a></span></li>
                                    <li><span class="right-at">March 10, 2016 at 10.30am</span></li>
                                    <li><a class="reply" href="#">Reply</a></li>
                                </ul>
                            <p>It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout.The point of using Lorem Ipsum is that it has a more-or-less </p>
                            </div>
                            <div class="clearfix"> </div>
                        </div>
                        <div class="comments-top-top top-grid-comment">
                            <div class="top-comment-left">
                                <a href="#"><img class="img-responsive" src="images/co.png" alt=""></a>
                            </div>
                            <div class="top-comment-right">
                                <ul>
                                    <li><span class="left-at"><a href="#">Admin</a></span></li>
                                    <li><span class="right-at">March 18, 2016 at 10.30am</span></li>
                                    <li><a class="reply" href="#">Reply</a></li>
                                </ul>
                            <p>It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout.The point of using Lorem Ipsum is that it has a more-or-less </p>
                            </div>
                            <div class="clearfix"> </div>
                        </div>
                    </div>          
                    <div class="artical-commentbox">
                        <h3>leave a comment</h3>
                        <div class="table-form">
                            <form>
                                <input placeholder="Name" type="text" required="">
                                <input placeholder="Email" type="email" required="">    
                                <input placeholder="Phone" type="text" required="">                                 
                                <textarea placeholder="Message"></textarea>
                                <input type="submit" value="Send">
                            </form>
                        </div>
                    </div>  
                </div>
            </div>
        </div>
    <!--single-page-->
@endsection

你可以在这里看到更多。https:/laravel.comdocs7.xblade

© www.soinside.com 2019 - 2024. All rights reserved.