1

FlashScopeがSpring3.1に統合されるのを待っている間(とにかくこのリリースで予定されています)、このバグ投稿に出くわしました。これにより、3.1がリリースされたときに利用可能になるはずのルーズバージョンを組み込むことができました。

私の問題は、FlashScopeにある値にバインドできないように見えることです。たとえば、私のモデルには次のコードがあります。

ModelAndView mav = new ModelAndView(someInjectedRedirectPage);
//Processing
mav.addObject("flashScope.someVar", someObject);

私のUIでは、Velocityを使用して、次の方法でこのオブジェクトにバインドしようとします。

##This is a velocimacro for those not familiar with velocity.
##It is basically like setting a path on a field utilizing the
##spring tag lib (e.x. <form:text path="flashScope")

#springBind("flashScope") 

ただし、そのバインディングを使用しようとすると、次の例外が発生します。

java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'flashScope' available as request attribute
at org.springframework.web.servlet.support.BindStatus.<init>(BindStatus.java:141)
at org.springframework.web.servlet.support.RequestContext.getBindStatus(RequestContext.java:720)bean name 'flashScope' available as request attribute...

ただし、ログには、リクエストに追加されたことを明確に記載できます。次のこともできます。

$flashScope.someVar.someProperty #The value prints fine this way.

とにかくMap値にバインドすることはできますか(これはバッキングコマンドオブジェクトではなく、要求だけにあります)?

次の場合に注意してください。

Map<String, String> map = new HashMap <String, String>(); 
map.put("key", "value");
mav.addObject("map", map);

まだマップにバインドできません...

この動作は、WebBindingInitializerを拡張することで変更できますか?FlashScopeMapを別のオブジェクトにラップするだけで問題は解決しますか?

4

1 に答える 1

0

別のオブジェクトにラップすることは、私がこの問題を解決することができた唯一の方法でした。

于 2011-04-25T19:33:18.047 に答える