java SpringWebflow验证两种类型的用户
我正在使用, 春季安全 Spring框架。 SpringWebFlow。 我想从同一登录页面验证两种不同类型的用户,即user1和user2。 它们在数据库中都有不同的表,并为它们定义了不同的实体类 我正在使用jsf。我的登录页面的xhtml页面。 我使用了PrimeFacesGUI,并借助于为user1和user2提供的登录页选项卡。 这是我的webflow定义文件
问题是我想从id为“welcome”的相同视图状态获取user1和user2的值,但我不知道如何接受它们的凭据,因为我指定了model=“student”,只允许使用1个模型
<?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="student" class="be.project.studNtwrk.domain.StudentEntity"/>
<var name="mentor" class="be.project.studNtwrk.domain.MentorEntity"/>
<view-state id="welcome" view="welcome.xhtml" model="student" >
<transition on="ssignUp" to="userType"></transition>
<transition on="msignUp" to="userType"></transition>
<transition on="studentSignIn" to="finish">
<evaluate expression="studentAuthenticationProviderService.processUserAuthentication(student)" />
</transition>
<transition on="mentorSignIn" to="finish">
<evaluate expression="mentorAuthenticationProviderService.processUserAuthentication(student)" />
</transition>
</view-state>
<view-state id="userType" view="ChooseUser.xhtml">
<transition on="student" to="studentsignup" />
<transition on="mentor" to="mentorsignup" />
</view-state>
<view-state id="studentsignup" view="studentregistration.xhtml" model="student">
<transition on="backToSignIn" to="welcome"></transition>
<transition on="backToChoice" to="userType"></transition>
<transition on="confirmSignUp" to="StudentAuthentication">
<evaluate expression="studentService.createUser(student)"></evaluate>
</transition>
</view-state>
<action-state id="StudentAuthentication">
<evaluate expression="studentAuthenticationProviderService.processUserAuthentication(student)" />
<transition on="yes" to="finish"></transition>
<transition on="no" to="welcome"></transition>
</action-state>
<view-state id="mentorsignup" view="mentorregistration.xhtml" model="mentor">
<transition on="backToSignIn" to="welcome"></transition>
<transition on="backToChoice" to="userType"></transition>
<transition on="confirmSignUp" to="MentorAuthentication">
<evaluate expression="mentorService.createUser(mentor)"></evaluate>
</transition>
</view-state>
<action-state id="MentorAuthentication">
<evaluate expression="mentorAuthenticationProviderService.processUserAuthentication(mentor)" />
<transition on="yes" to="finish"></transition>
<transition on="no" to="welcome"></transition>
</action-state>
<end-state id="finish" view="externalRedirect:account" />
</flow>
# 1 楼答案
您应该做的是将“学生”和“导师”各自分离到各自的流(文件)中,如果存在任何重复的逻辑,请使用流继承,并将重复的逻辑放在一个抽象流中,新的“学生”和“导师”流都会扩展该抽象流
http://docs.spring.io/spring-webflow/docs/current/reference/html/flow-inheritance.html