我正在尝试使用Spring Boot直接导航到我的角度应用程序中的URL,但是Spring只是提供了原始的json响应并且从未点击我的应用程序。我需要设置重定向吗?
proxy.conf.json
db.my_collection.count({"$or": [{"document_type_id": "3"}, {"document_type_id": "7"}]})
APP-routing.module.ts
{
"/": {
"target": "http://localhost:8080",
"secure": false
}
}
WebController.java
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { HomeComponent } from './home/home.component';
import { CollectionDatatableComponent } from 'app/datatable/collection/collection-datatable.component';
import { SearchDatatableComponent } from 'app/datatable/search/search-datatable.component';
const collectionRoutes: Routes = [
{ path: '', component: HomeComponent },
{ path: 'collection', component: CollectionDatatableComponent }
];
const routes: Routes = [
{ path: '', component: SearchDatatableComponent },
{ path: 'collection/:id/_contents', component: CollectionDatatableComponent, children: collectionRoutes }
];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule { }
export const appRoutingProviders: any[] = [];
结果
@Controller
public class WebController {
@Autowired
private FolderContentsService folderContentsService;
@GetMapping(value="/cmt/collection/{id}/_contents", produces=MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<FolderContentDto>> getFolderContents(@PathVariable("id") String id) throws Exception{
List<FolderContentDto> contentEntityList = folderContentsService.getFolderContents(id);
return new ResponseEntity<>(contentEntityList,HttpStatus.OK);
}
}