创建泛型方法以转发到抛出404的index.html请求

时间:2017-10-23 16:07:45

标签: spring angular spring-boot routing forwarding

<div uib-timepicker ng-model="item.StartDateTime" ng-change="vm.valueShiftChange(item)" onMouseOver="this.style.color='#00F'" hour-step="1" minute-step="1" show-meridian="true"></div> 个应用与Spring Boot相结合。我创建了一些路线但是当我输入Angular 4之类的字符串url时,我收到错误localhost:8080/items。这就是为什么我在404 not found检测到forwarding看起来像url转发到localhost:8080/items时创建index.html的原因。但是,当我有多个可能的urls打字并且我不想一次又一次地重新打击它的情况呢?

@RequestMapping(value = "/api/user", method = RequestMethod.POST)
@RequestMapping(value = "/api/user", method = RequestMethod.GET)
@RequestMapping(value = "/api/item", method = RequestMethod.GET)
@RequestMapping(value = "/api/item", method = RequestMethod.POST)
.
.
.
and so on

我想创建一些通用的东西,如:

@Controller
public class ViewController {

    @RequestMapping({ "/**" })
    public String index() {
        return "forward:/index.html";
    }
}

但它根本不起作用。或者还有另一种方法可以使它发挥作用?

1 个答案:

答案 0 :(得分:0)

这种情况的正确纠正是:

-Wsystem-headers添加

app.module

表示出现问题时应该怎么做并添加特定的 { path: '**', component: ItemListComponent}

java controller