2013-10-03 37 views
1

當我瀏覽/ app/wb/create時,我將進入下面的控制器方法,該方法需要調用流「/ app/main」,但是彈簧會將其重命名爲「/main.xhtml」。我的問題是如何重定向到從彈簧控制器流動?如何從@controller調用流?

@Controller 
@RequestMapping("/wb") 
public class HomeController { 

    private static final Logger logger = LoggerFactory.getLogger(HomeController.class); 

    /** 
    * Simply selects the home view to render by returning its name. 
    */ 

     @RequestMapping("/create/") 
     public String home(Device device, Model model) { 
      if (device == null) { 
       logger.info("no device detected"); 
      } else if (device.isNormal()) { 
       logger.info("Device is normal"); 
      } else if (device.isMobile()) { 
       logger.info("Device is mobile"); 
      } else if (device.isTablet()) { 
       logger.info("Device is tablet"); 
      } 
      return "app/main"; // Where main is the flow id 
     } 
} 

流量

<?xml version="1.0" encoding="UTF-8"?> 
<flow xmlns="http://www.springframework.org/schema/webflow" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://www.springframework.org/schema/webflow 
     http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd"> 

    <var name="user" class="com.veera.myapp.domain.UserEntity" /> 
    <view-state id="welcome" view="welcome.xhtml"> 
     <transition on="newUser" to="signUp" /> 
    </view-state> 

    <view-state id="signUp" view="signUp.xhtml" model="user"> 
     <transition on="backToSignIn" to="welcome" /> 
    </view-state> 
</flow> 

回答

0
return "/main"; 

你必須刪除你的應用程序的路徑

+0

請問能從流程中找到視圖嗎? – user1595858

+0

當我添加「/ main」時,它正在尋找/main.xhtml而不是webflow中的視圖主。 – user1595858

+0

默認情況下,流將以flow.xml中定義的第一個狀態開始 –

0
return "redirect:/main.xhtml" 

你必須告訴控制器重定向。

+0

它需要重定向到flow而不是xhtml頁面。 – user1595858

+0

什麼是您的webflow配置? – user926780

相關問題