I'm starting in the play framework with Java and downloaded the project from the official website: https://github.com/playframework/play-java-rest-api-example/tree/2.5.x
I joined the eclipse as it says at: https://www.playframework.com/documentation/2.5.x/IDE
And run the command: sbt run It worked. However, if I send a post to the given address, I get the message "Unauthorized".
Does anyone know if I have to do anything else?
Thank you very much in advance.
This is workin for me .
@Singleton public class Filters implements HttpFilters {
private final Environment env;
private final EssentialFilter exampleFilter;
@Inject
public Filters(Environment env, ExampleFilter exampleFilter) {
this.env = env;
this.exampleFilter = exampleFilter;
}
@Override
public EssentialFilter[] filters() {
if (env.mode().equals(Mode.DEV)) {
return new EssentialFilter[] { exampleFilter };
} else {
return new EssentialFilter[] {};
}
}
}
另一种方法是在application.conf文件中配置它,只需添加以下行
play.filters.disabled +="play.filters.cors.CORSFilter"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.