【发布时间】:2019-11-01 01:17:53
【问题描述】:
我想使用 JPA 和 mysql 来呈现页面 最后我得到了结果,但是格式不正确,有没有人知道解决方法?
ROOT - 기상 - 기압 - null ROOT - 기상 - 온도 - null ROOT - 기상 - 강수량 - null ROOT - 캘린더 - 최근1년 - null ROOT - 캘린더 - 최근5년 - null ROOT - 캘린더 - 최근10년 - null ROOT - 뉴스 - null - null
我得到了渲染结果,它没有包含“\n”是个问题,所以我想得到这样的结果
ROOT - 기상 - 기압 - null
ROOT - 기상 - 온도 - null
ROOT - 기상 - 강수량 - null
ROOT - 캘린더 - 최근1년 - null
ROOT - 캘린더 - 최근5년 - null
ROOT - 캘린더 - 최근10년 - null
ROOT - 뉴스 - null - null
包括多行,你能给我一些建议吗?
@RestController
@RequestMapping(value = "/Category")
@Slf4j
public class CategoryController {
@Autowired CategoryRepository categoryRepository;
@RequestMapping(value = "/all", method = RequestMethod.GET)
@ResponseBody
public String getCategoryList() {
List<String> sj = new ArrayList<String>();
//List<CategoryProjection> all= this.categoryRepository.findByCategory();
List<CategoryProjection> list = this.categoryRepository.findByCategory();
// loop i
for (int i = 0; i < list.size(); i++) {
sj.add(list.get(i).getLev1() + " - " + list.get(i).getLev2()+ " - "+list.get(i).getLev3() + " - " + list.get(i).getLev4());
}
String all = sj.stream().collect(Collectors.joining("\n"));
System.out.println(all);
return all;
//log.info(query);
//return "Test";
}
这是我的代码,所以我怎样才能修复它以获得保持正确格式的结果 谢谢你! 我的java版本JDK8
【问题讨论】:
标签: java spring-boot jpa format