[英]How do I serve resources when using my own handler mapping with Spring?
In my web application, pages are dynamically mapped to urls and pages can be added and removed. 在我的Web应用程序中,页面被动态映射到URL,并且可以添加和删除页面。 Hence, I wrote my own class extending AbstractUrlHttpHandlerMapping
and all requests are routed to one handler method. 因此,我编写了自己的扩展AbstractUrlHttpHandlerMapping
的类,所有请求都路由到一个处理程序方法。
However, now I don't want resources to be treated the same way, resources should just be returned as usually. 但是,现在我不希望以相同的方式对待资源,应该像往常一样返回资源。 How do I achieve this? 我该如何实现? I tried returning a ResourceHttpRequestHandler
for such resources, but I am not sure what to set PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE
to. 我尝试为此类资源返回ResourceHttpRequestHandler
,但不确定将PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE
设置PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE
。 My attempts ended in an NPE. 我的尝试以NPE结尾。
Is there a better way to return resources while using my own handler mapping? 使用我自己的处理程序映射时,是否有更好的方法返回资源?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.