當我瀏覽/ 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>
請問能從流程中找到視圖嗎? – user1595858
當我添加「/ main」時,它正在尋找/main.xhtml而不是webflow中的視圖主。 – user1595858
默認情況下,流將以flow.xml中定義的第一個狀態開始 –