2016-06-16 6 views
0

を表示するリダイレクトに失敗私は提出上のユーザー情報を更新春のフォームを持っているhere@ActionMappingは、Liferayのフォーラムに尋ね

を投稿してください。フォームは、フォームへの入力に関する成功/エラーメッセージとともに、保存後にユーザーをフォームに戻す必要があります。私の問題は、@ActionMappingformビューにリダイレクトすることができないことです。私はガイドhereに従ったが、運がなかった。

@ActionMapping(params ={"action=saveUser"}) 
public void saveUser(
    @ModelAttribute("user") User user, 
    BindingResult result, 
    ActionRequest actionRequest, 
    ActionResponse actionResponse) throws IOException {  
    ModelAndView mav = new ModelAndView("form"); 
    try { 
     userRepo.save(user); 
     mav.addObject("success", "User successfully saved"); 
     actionResponse.setRenderParameter("action", "success"); 
    } catch (Exception e){ 
     actionResponse.setRenderParameter("action", "failure"); 
    } 
} 


@RenderMapping(params = "action=success") 
public ModelAndView viewSuccess() { 
    ModelAndView mav = new ModelAndView("form"); 
    mav.addObject("success", "stuff"); 
    return mav; 
} 

@RenderMapping(params = "action=failure") 
public String viewFailure() { 
    ModelAndView mav = new ModelAndView("form"); 
    mav.addObject("failure", "other stuff"); 
    return mav; 
} 

ユーザーが後

が正常 viewSuccess()メソッドが呼び出されるべきで保存し、フォームを返すが、それが呼び出されることはありません。何か案は?あなたがあなたのポートレットの下 liferay-portlet.xmlに次の行

<action-url-redirect>true</action-url-redirect> 

が欠落しているよりも、言及したチュートリアルに従っている場合は

答えて

0

+0

私はLiferayの-portlet.xmlの中にこれを含めましたが、それは持っていませんでした私のリダイレクトの影響 –

+0

'' false '(これも' liferay-portlet.xml')では、これは空中でのショットです:p – KLajdPaja

+0

Iまた、良い仲間を宣言している –

関連する問題