Controller代码如下:
@SpringBootApplication
public class So49512910Application {
public static void main(String[] args) {
SpringApplication.run(So49512910Application.class, args);
}
@Bean
public Queue queue() {
return new Queue("someQueue");
}
@Bean
public Binding binding() {
return new Binding("someQueue", DestinationType.QUEUE, "topic_logs", "rk.pattern", null);
}
@RabbitListener(queues = "someQueue")
public void listener(String in) {
System.out.println(in);
}
}
在Views中我使用foreach编写代码如下:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\View;
use DarthSoup\Whmcs\Facades\Whmcs;
use DarthSoup\Whmcs\WhmcsServiceProvider;
class GetProductController extends Controller
{
public function show(){
$products = Whmcs::GetProducts([
'pid'=>'pid',
'name' =>'name',
'price' =>'price',
'description' =>'description'
]);
return view('main.SME_Hosting',['products'=>$products]);
}
}
我的Json数据如下: 我附上了JSON数据的屏幕截图,并提出了一种使用foreach循环打印所有这些数据的方法。
答案 0 :(得分:1)
您可以使用 @json 指令
获取传递数据的json格式var products = @json($products);
答案 1 :(得分:0)
您可以使用:
@foreach ($products as $product)
<pre>{{ $product | json }}</pre>
@endforeach
它将在json中打印所有产品数据。