小编Div*_*arg的帖子

如何从 Spring Boot 重定向/转发角度页面?

我正在开发一个前端为 angular 6,后端为 spring boot 的应用程序。在实现用户身份验证模块时,我想相应地在登录后重定向到学生和教职员工的家。

但是,我无法从 Spring Boot 重定向页面。在 Spring MVC 中使用从控制器操作重定向到外部 URL这个解决方案我收到 CORS 错误:“在预检响应中访问控制允许头不允许请求头字段内容类型。”

或者,如果有另一种方法来完成这项任务?

认证控制器.java

package sgsits.cse.dis.user.controller;

@CrossOrigin(origins = "*") // enables cross origin request
@RestController
@RequestMapping(value = "/dis")
@Api(value = "Authentication Resource")
public class AuthenticationController {

@Autowired
StudentRepository studRepo;
@Autowired
StaffRepository staffRepo;
@Autowired
EmailController email;

String pattern = "MM-dd-yyyy";
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);

@ApiOperation(value = "login", response = Object.class, httpMethod = "POST", produces = "application/json")
@RequestMapping(value = "/login", method = RequestMethod.POST) …
Run Code Online (Sandbox Code Playgroud)

java spring-boot angular

5
推荐指数
1
解决办法
5113
查看次数

标签 统计

angular ×1

java ×1

spring-boot ×1