小编koj*_*jot的帖子

映射所有请求而不是Spring Boot中的特定模式

我在Spring Boot应用程序内部有VueJS单页应用程序,我想让vue-router处理所有请求,而不是这些以url开头的请求/rest/**

因此,我编写了正则表达式^(?!/rest/).*以匹配不以开头的所有内容,/rest/然后尝试使请求映射如下:

@Controller
public class MainController {

@RequestMapping(value = "/{path:^(?!/rest/).*}")
    public String forwardRequests() {
        return "forward:/";
    }
}
Run Code Online (Sandbox Code Playgroud)

但这不起作用。我做错了什么?

编辑

我有休息控制器文件:

@RestController
@RequestMapping(path = "/rest/project")
public class ProjectController {

    @Autowired
    private ProjectService projectService;

    @GetMapping(value = "/{id}")
    public Project getProjectById(@PathVariable Long id) {
        return projectService.getProjectById(id);
    }
}
Run Code Online (Sandbox Code Playgroud)

它返回带有项目详细信息的JSON。我有一些类似的页面/login/projekty因此我需要转发它们index.html以处理vue路由。我知道我可以做这样的事情:

@Controller
public class MainController {

    @RequestMapping(value = {"/login", "/projekty"}, method = RequestMethod.GET)
    public String forwardRequests() {
        return "forward:/";
    }
} …
Run Code Online (Sandbox Code Playgroud)

regex spring spring-security spring-boot

7
推荐指数
1
解决办法
7086
查看次数

如何在 vue.js 中将数据传递给子组件

我是 vue.js 的新手,我尝试将值传递给子组件。

HTML

<div id="example">
   <my-component v-bind:data="parentData"></my-component>
</div>
Run Code Online (Sandbox Code Playgroud)

JS

Vue.component('my-component', {
  props: ['data'],
  template: '<div>Parent component with data: {{ data.value }}!<div is="my-component-child" v-bind:data="childData"></div></div>'
});

Vue.component('my-component-child', {
  props: ['data'],
  template: '<div>Child component with data: {{ data.value }} </div>'
});

new Vue({
  el: '#example',
  data: {
    parentData: {
      value: 'hello parent!'
    },
    childData: {
      value: 'hello child!'
    }
  }
});
Run Code Online (Sandbox Code Playgroud)

https://jsfiddle.net/v9osont9/2/

我有这个错误:

[Vue 警告]:属性或方法“childData”未在实例上定义,但在渲染期间被引用。确保在数据选项中声明反应数据属性。(在发现 )

[Vue 警告]:渲染函数出错:(在 中找到)

类型错误:无法读取未定义的属性“值”

这样做的正确方法是什么?

vue.js vue-component vuejs2

3
推荐指数
1
解决办法
4598
查看次数

Vavr - 将列表列表转换为单个列表

我有两个vavr列表:

List<Object> list1 = List.of("one", "two", "three", "for");
List<Object> list2 = List.of("one", "two", List.of("three", "for"));
Run Code Online (Sandbox Code Playgroud)

我怎样才能将其变换list2为等于list1

编辑

我试着解释一下我想要达到的目标:

System.out.println("list1: " + list1);
System.out.println("list2: " + list2);
Run Code Online (Sandbox Code Playgroud)

输出:

list1: List(one, two, three, for)
list2: List(one, two, List(three, for))
Run Code Online (Sandbox Code Playgroud)

我想要展平所有内部列表list2,因此展平列表应该等于list1:

System.out.println("flattened: " + flattened);
System.out.println(list1.equals(flattened));
Run Code Online (Sandbox Code Playgroud)

应该返回:

flattened: List(one, two, three, for)
true
Run Code Online (Sandbox Code Playgroud)

java collections vavr

-1
推荐指数
1
解决办法
274
查看次数