开发者

Spring mvc:mapping path rules

I need to map interceptor for all methods in annotated cont开发者_StackOverflowroller with @RequestMapping(value = "/client")

In mapping I have

<mvc:interceptor>
   <mvc:mapping path="/app/client/*"/>
   <bean class="com.cci.isa.web.CIPClientHandleInterceptor" />
</mvc:interceptor>

This interceptor called perfectly for urls like:

1. http://host/app/client/clientUpdateForm?clientId=305

But doesn't called for urls like:

2. http://host/app/client/clientUpdateForm/clientId_305 (with slash after method name)

How get it called for second variant?

Thanks a lot.


This question is too old, but maybe this helps somebody.

You should try removing /app, I think it's not necessary and perhaps this is causing the problem.

<mvc:mapping path="/client/**"/>


I think this will achieve what you would like:

<mvc:mapping path="/app/client/**/*"/>

The '/**' suggests any number of directories. When this is used in conjunction with '/*', you have something that looks at an arbitrary folder depth, with an arbitrary file name.


If your controller with

@RequestMapping(value = "/client")

Try

<mvc:mapping path="/client**"/>


Try the above suggestion but change the annotation to

@RequestMapping(value = "/client*")

Although I would use two methods for each of the two URI patterns and pass them to the one common method to do the "stuff"...

@RequestMapping(value = "/app/client/clientUpdateFormat/{clientId}", method = RequestMethod.GET)
 public String doItOne(@PathVariable("clientId") String clientId) {
    doItCommon(clientId);

and

@RequestMapping(value = "/app/client/clientUpdateFormat", method = RequestMethod.GET)
 public String doItTwo(@RequestParam("clientId")  String clientId) {
    doItCommon(clientId);


My problem was, that we used custom RequestMappingHandlerMapping

<bean name="handlerMapping" 
class="utils.web.versioning.MobileVersionRewritingMappingHandler">
    <property name="order" value="0"/> 
    <property name="interceptors"> 
        <list> 
          ...
        </list> 
    </property>  
</bean>

XML or code config for CORS or any other MVC properties doesn't affect custom handler mappings. I could specify cors config for custom handler mapping, but I prefer to remove legacy config and use this to configure interceptors:

 <mvc:interceptors>
  ...
 </mvc:interceptors>

Now cors is working and I'm using XML global cors configuration.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜