如何从@controller调用流?

时间:2013-10-03 22:16:34

标签: spring-mvc spring-webflow

当我导航/ app / wb / create时,我将进入下面的控制器方法,该方法需要调用流“/ app / main”,但是春天将其恢复为“/main.xhtml”。我的问题是如何从弹簧控制器重定向到流量?

@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>

2 个答案:

答案 0 :(得分:0)

return "/main";

您必须删除应用程序路径

答案 1 :(得分:0)

return "redirect:/main.xhtml"

你必须告诉控制器重定向。