问题
I have a simple gateway that implemented with zuul as you can see below:
application.properties
file:
zuul.routes.looli.url=http://localhost:8082
ribbon.eureka.enabled=false
server.port=8070
RoutingAndFilteringGatewayApplication
class:
@EnableZuulProxy
@SpringBootApplication
public class RoutingAndFilteringGatewayApplication {
public static void main(String[] args) {
SpringApplication.run(RoutingAndFilteringGatewayApplication.class, args);
}
@Bean
public SimpleFilter simpleFilter() {
return new SimpleFilter();
}
}
and the SimpleFilter
class:
public class SimpleFilter extends ZuulFilter {
private static Logger log = LoggerFactory.getLogger(SimpleFilter.class);
@Override
public String filterType() {
return "pre";
}
@Override
public int filterOrder() {
return 1;
}
@Override
public boolean shouldFilter() {
return true;
}
@Override
public Object run() {
RequestContext ctx = RequestContext.getCurrentContext();
HttpServletRequest request = ctx.getRequest();
log.info(String.format("%s request to %s", request.getMethod(), request.getRequestURL().toString()));
return null;
}
}
and this is the structure of looli application:
src
|_main
|_java
|_resources
|_webapp
|_dist
| |_js
| |_css
| |_img
|
|_index.html
Now, when i enter localhost:8070/looli in the browser it loads index.html, but get 404 error for all of static resources under dist directory.
NOTE
After i googled my problem, i found this question on SO and also checked his solution by creating looli folder under resources, but didn't affect.
I'm new to zull ;)
来源:https://stackoverflow.com/questions/62991711/spring-cloud-zuul-does-not-load-static-resources-from-spring-boot-applications