2 つのコントローラ (JSP ごとに 1 つ) を持つ 2 つの JSP ページがあります。
- Landing.jspx は検索フォームで、POST 経由で Landing Controller に送信されます。
- appt.jspx は、appt コントローラーによって提供される 2 番目のページです。
ランディングjspからappt jspに転送しようとしています。私は着陸管制官を次のようにマークしています:
@Controller
@SessionAttributes("state")
@RequestMapping(value = "/landing")
public class LandingController {
@RequestMapping(value = "/postData", method = RequestMethod.POST)
public String lookup(@ModelAttribute("state") State state, Model model) {
// something useful goes here
return "appt";
}
}
そして私の ApptController:
Spring のデバッグ ログ情報から、次のことがわかります。
- 私の着陸コントローラーは appt.jspx を返してレンダリングしています
- 「InternalResourceView 'appt' のリソース [/WEB-INF/jsp/appt.jspx] への転送」と表示されます
ブラウザに新しいページが表示されません。また、Spring が URL をログ内の appt コントローラ メソッドに一致させようとしている様子も見られません。appt コントローラーが要求を認識したことがないと仮定する必要があります。
これが私のapptコントローラーメソッドです(Springが実行しています):
@Controller
@SessionAttributes("state")
@RequestMapping(value="/appt")
public class ApptController {
@RequestMapping(method = RequestMethod.GET)
public String home(@ModelAttribute("state") PAWState state, Model model) {
model.addAttribute("state", state);
return "appt";
}
使用:
return "redirect:/appt"
それは私を近づけます、私は見ます:
- 私の着陸コントローラーは appt.jspx を返してレンダリングしています
- DispatcherServlet が URL /appt と一致させようとしており、appt コントローラーで正しいメソッドを見つけていることがわかります。
- SpringがRenderedと言うビュー「appt」を返すapptコントローラーメソッドが表示されます
表示されないのは、ブラウザの新しいレンダリングです。同じ検索ページが表示されます。
私は何が欠けていますか?
ログ (「redirect:/appt」を返す):
12:53:40,451 DEBUG - DispatcherServlet with name 'XServlet' processing POST request for /X/landing/postData]
12:53:40,451 DEBUG - Looking up handler method for path /landing/postData
12:53:40,451 DEBUG - Returning handler method [public java.lang.String x.x.x.x.controller.LandingController.lookup(x.x.x.x.controller.valuebeans.XState,org.springframework.ui.Model) throws x.x.x.x.common.exception.XException]
12:53:40,451 DEBUG - Returning cached instance of singleton bean 'LandingController'
12:53:40,732 DEBUG - Invoking afterPropertiesSet() on bean with name 'redirect:/appt'
12:53:40,732 DEBUG - Rendering view [org.springframework.web.servlet.view.RedirectView: name 'redirect:/appt'; URL [/appt]] in DispatcherServlet with name 'XServlet'
12:53:40,732 DEBUG - Successfully completed request
12:53:40,732 DEBUG - DispatcherServlet with name 'XServlet' processing GET request for [/X/appt]
12:53:40,732 DEBUG - Looking up handler method for path /appt
12:53:40,732 DEBUG - Returning handler method [public java.lang.String x.x.x.x.controller.ApptController.home(x.x.x.x.controller.valuebeans.XState,org.springframework.ui.Model) throws x.x.x.x.common.exception.XException]
12:53:40,732 DEBUG - Returning cached instance of singleton bean 'apptController'
12:53:40,732 DEBUG - Last-Modified value for [/X/appt] is: -1
12:53:40,732 DEBUG - Invoking afterPropertiesSet() on bean with name 'appt'
12:53:40,732 DEBUG - Rendering view [org.springframework.web.servlet.view.JstlView: name 'appt'; URL [/WEB-INF/jsp/appt.jspx]] in DispatcherServlet with name 'XServlet'
12:53:40,732 DEBUG - Added model object 'org.springframework.validation.BindingResult.state' of type [org.springframework.validation.BeanPropertyBindingResult] to request in view with name 'appt'
12:53:40,732 DEBUG - Added model object 'state' of type [x.x.x.x.controller.valuebeans.XState] to request in view with name 'appt'
12:53:40,732 DEBUG - Forwarding to resource [/WEB-INF/jsp/appt.jspx] in InternalResourceView 'appt'
12:53:42,979 DEBUG - No properties file found for [file:/C:/Work/x/WEB-INF/messageSource/content_en_US] - neither plain properties nor XML
12:53:42,979 DEBUG - No properties file found for [file:/C:/Work/x/WEB-INF/messageSource/content_en] - neither plain properties nor XML
12:53:42,979 DEBUG - Loading properties [content.properties]
12:53:43,010 DEBUG - No property editor [java.lang.BooleanEditor] found for type java.lang.Boolean according to 'Editor' suffix convention
12:53:43,026 DEBUG - Successfully completed request
編集:これは注釈を使用したSpring 3.1.1経由です