我必须使用Java构建在线电子商务网站.因为我想使用像jQuery/prototupe/moottols这样的AJAX库,有人告诉我去基于请求/操作的框架,因为我来自web开发背景.
所以我开始学习Spring.我做过Spring DI和AOP.
有人可以指导我,为了达到我使用spring和JQuery(与html页面相同)开发电子商务网站的目标,我还有什么需要学习的东西
我应该去Spring MVC或网络流程还是相同的.我很迷惑.请帮我
另外,我是否需要了解Spring MVC或Web流的servlet和JSP?有人告诉我不要做旧的servlet/JSP事情.
或者我必须学习春季MVC.我可以花一周的时间来获得基础知识,但我不知道该怎么做
验证问题
当方法"注册"时我会运行验证
在webflow中:...
<transition on="registered" to="registeredAction" bind="true" validate="true" />
Run Code Online (Sandbox Code Playgroud)
...
我的模型看起来像这样:
class User {
private String name;
private String surname;
...
private List <address> addresses;
...
public void validateRegistered (ValidationContext context) {
Context.getMessageContext MessageContext messages = ();
if (name == null) {
messages.addMessage (new MessageBuilder (.) error (). source ("name".) code (MessageCodes.Error.REQUIRED.) build ());
}
}
Run Code Online (Sandbox Code Playgroud)
在Address类中
Class Address {
private String street;
private String city;
public void validateRegistered (ValidationContext context) {
Context.getMessageContext MessageContext messages = ();
if (street == …Run Code Online (Sandbox Code Playgroud) 我从主流中调用子流.我已经能够ShareHolderProfile从MainFlow 将对象传递给SubFlow.但是,我不确定这个相同的对象是否没有被传递回MainFlow,或者我在JSP中没有正确访问它.我是这样做的.
<?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"
start-state="retriveAccount">
<var name="acctProfile" class="com.abc.xyz.account.ShareHolderProfile"/>
<view-state id="retriveAccount" view="AccountView">
<transition on="Success" to="createAccountSubFlow"/>
</view-state>
<subflow-state id="createAccountSubFlow" subflow="createAccountSubFlow">
<input name="acctProfile" value="acctProfile"/>
<transition on="finish" to="showAlternateRoute"/>
</subflow-state>
<view-state id="showAlternateRoute" view="showAlternateView" model="acctProfile">
<on-entry>
<evaluate someExpression result="viewScope.SomeValue"/>
</on-entry>
<transition on="viewAction" to="accountDetails"/>
</view-state>
Run Code Online (Sandbox Code Playgroud)
<?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"
start-state="showAccount">
<input name="acctProfile" />
<view-state id="showAccount" view="randomView" model="acctProfile">
<on-entry>
<evaluate expression="SomExpression"/>
</on-entry>
<transition on="SomeEvent" to="NextState"/>
</view-state>
<view-state id="NextState" view="SomeRandomView" model="acctProfile">
<on-entry>
<evaluate expression="controller.Method(acctProfile)" result="viewScope.profileForm"/> …Run Code Online (Sandbox Code Playgroud) 如何防止异常,如果requestParameters.sortBy传递为string(java.lang.NumberFormatException)或缺少(java.lang.NullPointerException)?
<view-state id="journeySearch" model="journeyForm">
...
<transition on="sort">
<set name="journeyCriteria.sortBy" value="requestParameters.sortBy" type="int" />
<evaluate expression="bookingService.searchJourneys(journeyCriteria)" result="viewScope.journeys" />
</transition>
</view-state>
Run Code Online (Sandbox Code Playgroud) 我正在寻找使用 Spring Security 在整个应用程序中存储和显示登录用户的其他详细信息的正确方法。
例如,我想在每一页的顶部显示Welcome:Mr.Smith(管理员,数学部)。为此,我想获取登录用户的前缀、姓氏、名称和部门。
我正在使用自定义UserDetails服务从数据库中获取用户。在浏览时,我发现AuthenticationhasgetDetails()可以存储与身份验证相关的其他详细信息,我可以使用该方法存储其他详细信息吗?
如果是,你能举一个简单的例子吗?我可以AuthenticationSuccessHanlder用来做这项工作,还是我以完全错误的方式看待问题?我不应该在 spring 安全层处理这个吗?我应该在哪里照顾它?
我是Spring Webflow的新手,我正在尝试修改现有的流来检查用户根据几个规则使用流的授权.似乎没有一种明显的(广泛记录的)从评估过渡到某种终止条件的方法.我理解的转换不允许在开始时使用.抛出异常除了有一种优雅的过渡方式吗?谢谢.
这是为编辑创建的表单.我将授权检查代码添加到引用的方法中.我可以在此之前添加一个单独的评估来检查授权,但我仍然有转换问题.
<on-start>
<evaluate expression="solutionCreateEditFlowHelper.findDocumentForEdit(requestParameters.solutionId)" result="flowScope.documentForm"></evaluate>
Run Code Online (Sandbox Code Playgroud)
>
我想将Spring Web Flow主要用于其PRG功能.
假设我有类似于/widget/edit/99或的URL /widget/edit/123,其中数字代表id小部件.
我怎样才能开始/widget/edit流动,传入id?
默认情况下,流URL看起来必须与流名称文件夹结构匹配.
我想保留网址/widget/edit/99而不是重定向.
(使用v 2.4)
有人可以帮我理解Spring Web Flow的优点.我所理解的是
还有其他我没有调整过的吗?
关于Grails Web流程的第一个状态的一些问题:
我正在使用spring mvc 3和webflow 2.我一直在关注在线资源,并一直试图让一个例子正常工作.我无法使webflow url映射生效.只有网络流不工作,mvc部分工作正常.
我一直得到的错误是:在名为'appServlet'的DispatcherServlet中找不到带有URI [/ Project2Admin/pizza]的HTTP请求的映射
我在下面粘贴了我的servlet-context.xml.
非常感谢您的帮助!欧弟
servlet的context.xml中
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:flow="http://www.springframework.org/schema/webflow-config"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/webflow-config http://www.springframework.org/schema/webflow-config/spring-webflow-config-2.0.xsd">
<!-- DispatcherServlet Context: defines this servlet's request-processing infrastructure -->
<!-- Enables the Spring MVC @Controller programming model -->
<annotation-driven/>
<!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/resources directory -->
<resources mapping="/resources/**" location="/resources/" />
<beans:bean class="org.springframework.web.servlet.view.tiles2.TilesViewResolver"/>
<beans:bean class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
<beans:property name="definitions">
<beans:list>
<beans:value>/WEB-INF/views/**/views.xml</beans:value>
</beans:list>
</beans:property>
</beans:bean> …Run Code Online (Sandbox Code Playgroud) spring-webflow ×10
spring ×6
java ×3
spring-mvc ×2
grails ×1
groovy ×1
url-mapping ×1
validation ×1