我正在使用webapp, 春天的安全 Spring框架。 春天webflow。 我想从相同的登录页面验证两个不同类型的用户,即user1和user2。 两者在数据库中都有不同的表,并为它们定义了不同的实体类 我正在使用jsf .xhtml页面登录我的登录页面。 我使用了primefaces gui并在tab的帮助下为user1和user2提供了登录页面。 这是我的webflow定义文件。
问题是我想从id为“welcome”的相同视图状态获取user1和user2的值但我不知道如何接受他们的凭证,因为我只允许1个模型,因为我指定了model =“student”
<?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>
答案 0 :(得分:0)
你应该做的是分开学生&#34;和&#34;导师&#34;每个进入自己的流(文件),如果有任何重复的逻辑使用流继承,并将重复的逻辑放在一个抽象的流程中,新的&#34;学生&#34;和&#34;导师&#34;流量扩大。
http://docs.spring.io/spring-webflow/docs/current/reference/html/flow-inheritance.html