我在我的前端使用Angular 4,在后端使用Laravel 5.2.我想从UI导入Excel工作表,将值存储在DB中,检索值并使用Angular在UI中显示它们.
我在laravel中使用Maatwebsite/Excel包.我的excel表具有以下结构.
名字| 细节| 价格
expertphp | 在线教程| 100
你好| 代码| 200
我的laravel代码如下:这里myFile是具有文件路径和名称作为其值的键.
$File = $request->file('myFile');
$path = $request->file('myFile')->getRealPath();
$real_name = $File->getClientOriginalName();
$data = Excel::load($path)->get();
if($data->count()){
foreach($data as $key => $value){
$arr[] = ['name' => $value->name, 'details' => $value->details, 'price' => $value->price];
}
}
return response()->success($data);
Run Code Online (Sandbox Code Playgroud)
我收到如下响应:
{
"errors":false,
"data":[
{
"namedetailsprice":"expertphp\tOnline tutorials\t100"
},
{
"namedetailsprice":"hello\tfirst code\t2000"
}
]
}
Run Code Online (Sandbox Code Playgroud)
我不明白为什么标题会成为一个字段.感谢任何帮助.
谢谢.
我正在开发一个 Spring Boot 应用程序。我在点击我配置的 URL 路径时收到404 错误。我哪里错了?
主控制器.java
package com.example.homes;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController("/add")
public class HomeController {
@GetMapping("/hello")
public String add() {
return "Hello";
}
}
Run Code Online (Sandbox Code Playgroud)
主页应用程序.java
package com.example.homes;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@SpringBootApplication
public class HomeApplication {
public static void main(String[] args) {
SpringApplication.run(HomeApplication.class, args);
System.out.println("Inside main");
}
}
Run Code Online (Sandbox Code Playgroud)