org.apache.jasper.JasperException:javax.el.PropertyNotFoundException:类'java.lang.String'没有属性'user'

问题描述 投票:0回答:1

我正在使用spring webflow 我的jsp页面是

<!-- header -->
<%@include file="../shared/flows-header.jsp"%>

<div class = "container">


<div class = "row">

<div class = col-sm-6>

    <div class = "panel panel-primary">

        <div class = "panel-heading">

            <h4>Personal Details</h4>

        </div>

        <div class = "panel-body">

            <!-- to display personal details -->
                    <div class="text-center">
                        <h3>Name : <strong>${registerModel.user.firstname} ${registerModel.user.lastname}</strong></h3>
                        <h4>Email : <strong>${registerModel.user.email}</strong></h4>
                        <h4>Contact : <strong>${registerModel.user.contactNumber}</strong></h4>
                        <h4>Role : <strong>${registerModel.user.role}</strong></h4>

                    </div>

                    <!-- anchor tag to move to personal details page to edit -->
                    <p>
                        <a href = "${flowExecutionUrl}&_eventId_personal" class = "btn btn-primary">Edit</a>        
                    </p>
        </div>

    </div>

</div>


<div class = col-sm-6>

    <div class = "panel panel-primary">

        <div class = "panel-heading">

            <h4>Billing Address</h4>

        </div>

        <div class = "panel-body">

            <!-- to display billing address -->
                    <div class="text-center">
                        <p>${registerModel.billing.addressLineOne}, </p>
                        <p>${registerModel.billing.addressLineTwo}, </p>
                        <p>${registerModel.billing.city} -  ${registerModel.billing.postalCode}, </p>
                        <p>${registerModel.billing.state}</p>
                        <p>${registerModel.billing.country}</p>
                    </div>      

            <!-- anchor tag to move to billing address page to edit -->
            <p>
                <a href = "${flowExecutionUrl}&_eventId_billing" class = "btn btn-primary">Edit</a>
            </p>

        </div>

    </div>

</div>

<div class = "row">

    <div class = "col-sm-4 col-sm-offset-4">

        <div class = "text-center">

            <!-- anchor tag to move to success page -->
            <a href = "${flowExecutionUrl}&_eventId_submit" class = "btn btn-primary">Confirm Submission</a>

        </div>

    </div>

</div>

</div>

</div>

<!-- footer -->
<%@include file="../shared/flows-footer.jsp"%>

我的signup-flow.xml页面是

<?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.xsd">

    <var  name = "user" class = "model.entity.User" />
    <var  name = "billing" class = "model.entity.Address" />

    <on-start>
        <evaluate expression="'registerHandler.init()'" result = "flowScope.registerModel" />
    </on-start>


    <!-- start state -->
    <view-state id = "personal" view = "flows/register/signup-personal" model = "'user'"><!-- model value is used as modelAttribute in spring form -->
        <transition on = "billing" to = "billing" /><!-- to billing view state -->
        <on-exit>
            <evaluate expression="'registerHandler.addUser(flowScope.registerModel , user)'" />
        </on-exit>
     </view-state>

    <view-state id = "billing" view = "flows/register/signup-billing" model = "'billing'">
        <transition on = "personal" to = "personal" />
        <transition on = "confirm" to = "confirm" />
        <on-exit>
            <evaluate expression="'registerHandler.addBilling(flowScope.registerModel , billing)'" />
        </on-exit>
     </view-state>

    <view-state id = "confirm" view = "flows/register/signup-confirm" model = "flowScope.registerModel">
        <transition on = "personal" to = "personal" />
        <transition on = "billing" to = "billing" />
        <transition on = "submit" to = "submit" />  
     </view-state>

    <action-state id="submit">
        <evaluate expression="'registerHandler.saveAll(flowScope.registerModel)'" />
        <transition on = "success" to = "success" />
    </action-state>

    <!-- end state -->
    <end-state id = "home" view = "externalRedirect:contextRelative:/" />
    <end-state id = "success" view = "flows/register/signup-success" />


    <!-- global transition -->
    <global-transitions>
        <transition on = "home" to = "home"/>
    </global-transitions>

</flow>

**错误堆栈跟踪是**

错误[io.undertow.request](默认任务-5)UT005023:对/OnlineShoppingFE/views/flows/register/signup-confirm.jsp的异常处理请求:org.springframework.web.util.NestedServletException:请求处理失败;嵌套异常是org.springframework.webflow.execution.FlowExecutionException:在org.springframework.web异常在org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)中流动的“注册”状态“确认”抛出.servlet.FrameworkServlet.doGet(FrameworkServlet.java:890)位于org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:875)的javax.servlet.http.HttpServlet.service(HttpServlet.java:687) javax.servlet.http.HttpServlet.service(HttpServlet.java:790)at io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74)at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest( ServletSecurityRoleHandler.java:62)ato.undertow.servlet.handlers.ServletChain $ 1.handleRequest(ServletChain.java:68)atg.wildfly的io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)。 extension.undertow.security.SecurityContextAssociationHandle r.handleRequest(SecurityContextAssociationHandler.java:78)at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:132)位于io.undertow.security.handle.handle处理的io.undertow.server.handle上的io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)中的io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest(ServletAuthenticationCallHandler.java:57).AbstractConfidentialityHandler .handleRequest(AbstractConfidentialityHandler.java:46)at io.undertow.servlet.handlers.security.ServletConfidentialityConstraintHandler.handleRequest(ServletConfidentialityConstraintHandler.java:64)at io.undertow.security.handlers.AuthenticationMechanismsHandler.handleRequest(AuthenticationMechanismsHandler.java:60)at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler .java:77)io.undertow.security.handlers.NotificationReceiverHandler.handleRequest(NotificationReceiverHandler.java:50)at io.undertow.server的io.undertow.security.handlers.AbstractSecurityContextAssociationHandler.handleRequest(AbstractSecurityContextAssociationHandler.java:43)。 handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)atg.wildfly.extension.undertow.security.jacc.JACCContextIdHandler.handleRequest(JACCContextIdHandler.java:61)at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler。 java:43)org.wildfly.extension.undertow.deployment.GlobalRequestControllerHandler.handleRequest(GlobalRequestControllerHandler.java:68)at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)at io.undertow.servlet .handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:292)在io.undertow.servlet.handlers.ServletInitialHandler.access $ 100(ServletInitialHandler.java:81)在io.undertow.servlet.handler s.ServletInitialHandler $ 2.call(ServletInitialHandler.java:138)at io.undertow.servlet.handlers.ServletInitialHandler $ 2.call(ServletInitialHandler.java:135)at io.undertow.servlet.core.ServletRequestContextThreadSetupAction $ 1.call(ServletRequestContextThreadSetupAction.java) :48)在组织的org.wildfly.extension.undertow.security.SecurityContextThreadSetupAction.lambda $ create $ 0(SecurityContextThreadSetupAction.java:105)的io.undertow.servlet.core.ContextClassLoaderSetupAction $ 1.call(ContextClassLoaderSetupAction.java:43)。 wildd.extension.undertow.deployment.UndertowDeploymentInfoService $ UndertowThreadSetupAction.lambda $ create $ 0(UndertowDeploymentInfoService.java:1514)org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService $ UndertowThreadSetupAction.lambda $ create $ 0(UndertowDeploymentInfoService.java:1514)at at org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService $ UndertowThreadSetupAction.lambda $ create $ 0(UndertowDeploymentInfoService.java:1514)org.wi ldfly.extension.undertow.deployment.UndertowDeploymentInfoService $ UndertowThreadSetupAction.lambda $ create $ 0(UndertowDeploymentInfoService.java:1514)at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:272)at io.undertow.servlet.handlers .ServletInitialHandler.access $ 000(ServletInitialHandler.java:81)at io.undertow.servlet.handlers.ServletInitialHandler $ 1.handleRequest(ServletInitialHandler.java:104)at io.undertow.server.Connectors.executeRootHandler(Connectors.java:360)at at io.undertow.server.HttpServerExchange $ 1.run(HttpServerExchange.java:830)在org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)在org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1985 )org.jboss.threads.EnhancedQueueExecutor $ ThreadBody.doRunTask(EnhancedQueueExecutor.java:1487)at org.jboss.threads.EnhancedQueueExecutor $ ThreadBody.run(EnhancedQueueExecutor.java:1378)at java.lang.Thread.run(Unknow n源)引起:org.springframework.webflow.execution.FlowExecutionException:在org.springframework.webflow.engine.impl.FlowExecutionImpl.wrap(FlowExecutionImpl.java:573)的流'register'的'confirm'状态中抛出异常at Org.springframework.webflow.engine.impl.FlowExecutionImpl.resume(FlowExecutionImpl.java:263)位于org.springframework.webflow.mvc.servlet的org.springframework.webflow.executor.FlowExecutorImpl.resumeExecution(FlowExecutorImpl.java:169)。位于org.springframework.web.servlet.DispatcherServ。 java.lang.IllegalStateException:.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:998)... 45更致发生异常渲染视图org.springframework.web.servlet.view.JstlView:名称“流/注册/注册-确认“;位于org.springframework.webflow.engine.ViewState.render(ViewState)的org.springframework.webflow.mvc.view.AbstractMvcView.render(AbstractMvcView.java:200)中的URL [/views/flows/register/signup-confirm.jsp] .java:293)org.springframework.webflow.engine.ViewState.refresh(ViewState.java:242)位于org.springframework.webflow的org.springframework.webflow.engine.ViewState.resume(ViewState.java:220)。 engine.Flow.resume(Flow.java:537)at org.springframework.webflow.engine.impl.FlowExecutionImpl.resume(FlowExecutionImpl.java:259)... 50 more引起:org.apache.jasper.JasperException:javax .el.PropertyNotFoundException:类'java.lang.String'没有属性'user'。 org.apache.jache上的org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:473)org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:403)org.apache.jasper.servlet.JspServlet.service (jspServlet.java:347)位于io.undertow.servlet的io.undertow.servlet.handlers.ServletHandler.handleRequest(ServletHandler.java:74)的javax.servlet.http.HttpServlet.service(HttpServlet.java:790)。 handler.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:62)at io.undertow.jsp.JspFileHandler.handleRequest(JspFileHandler.java:32)at io.undertow.servlet.handlers.ServletChain $ 1.handleRequest(ServletChain.java:68 )io.undertow.servlet.handle.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:43)at io.undertow.server.handlers.PredicateHandler。 handleRequest(PredicateHandler.java:43)at io.undertow.server.handlers.PredicateHandler.handleRequest(Predi) cateHandler.java:43)io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:274)at io.undertow.servlet.handlers.ServletInitialHandler.dispatchToPath(ServletInitialHandler.java:209)at io.undertow.servlet .spec.RequestDispatcherImpl.forwardImpl(RequestDispatcherImpl.java:221)at io.undertow.servlet.spec.RequestDispatcherImpl.forwardImplSetup(RequestDispatcherImpl.java:147)at io.undertow.servlet.spec.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:111 )在org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:170)在org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:316)在org.springframework.webflow。 javax.el.PropertyNotFoundException:mvc.servlet.ServletMvcView.doRender(ServletMvcView.java:55)在org.springframework.webflow.mvc.view.AbstractMvcView.render(AbstractMvcView.java:196)...... 55多由此造成的class'java.lang.String'没有该属性“用户”。在javax.el.BeanELResolver.getBeanProperty(BeanELResolver.java:568)的javax.el.BeanELResolver.getValue(BeanELResolver.java:229)at org.apache.jasper.el.JasperELResolver.getValue(JasperELResolver.java:110)at at com.sun.el.parser.AstValue.getValue(AstValue.java:139)com.sun.el.parser.AstValue.getValue(AstValue.java:203)com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl。的java:226)在org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:917)在org.apache.jsp.views.flows.register.signup_002dconfirm_jsp._jspService(signup_002dconfirm_jsp.java:230)在org.apache .jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)位于org.apache.jasper.servlet.JspServletWrapper.service的javax.servlet.http.HttpServlet.service(HttpServlet.java:790)中(JspServletWrapper.java:433) )......还有75个

RegisterModel类是

package flow.model;

import java.io.Serializable;

import model.entity.Address;
import model.entity.User;

public class RegisterModel implements Serializable {

    /**
     * 
     */
    private static final long serialVersionUID = 1L;

    private User user;

    private Address billing;

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    public Address getBilling() {
        return billing;
    }

    public void setBilling(Address billing) {
        this.billing = billing;
    }


}

RegisterHandler类

package handler;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import flow.model.RegisterModel;
import model.dao.IUserDAO;
import model.entity.Address;
import model.entity.Cart;
import model.entity.User;

@Component
public class RegisterHandler {

    @Autowired
    private IUserDAO userDAO;

    public RegisterModel init()
    {
        System.out.println(new RegisterModel().toString());
        return (new RegisterModel());
    }

    public void addUser(RegisterModel registerModel,User user)
    {
        registerModel.setUser(user);
    }

    public void addBilling(RegisterModel registerModel,Address billing)
    {
        registerModel.setBilling(billing);
    }

    public String saveAll(RegisterModel model)
    {
        String transitionValue = "success";

        //fetch user
        User user = model.getUser();

        if(user.getRole().equals("ROLE"))
        {
            Cart cart = new Cart();
            cart.setUser(user);
            user.setCart(cart);
        }

        //save user
        userDAO.addUser(user);

        //get address
        Address billing = model.getBilling();   
        billing.setUserId(user.getId());
        billing.setBilling(true);

        //save the address
        userDAO.addAddress(billing);

        return transitionValue;
    }

}
java xml spring jsp spring-webflow
1个回答
1
投票

我在那里看到了几个可能的误解,但我认为主要的一个是你在属性上使用单引号,你不应该。造成这一特殊问题的原因是:

<evaluate expression="'registerHandler.init()'" result = "flowScope.registerModel" />

你输入flowScope.registerModel,字符串值“registerHandler.init()”,而不是调用registerHandler.init()的结果。

相反,删除单引号,如下所示:

<evaluate expression="registerHandler.init()" result = "flowScope.registerModel" />

对于后面的引用也是如此:

   <view-state id = "billing" view = "flows/register/signup-billing" model = "'billing'">

这也应该没有“结算”的单引号:

   <view-state id = "billing" view = "flows/register/signup-billing" model = "billing">

(另外,通过声明<var>s“user”和“billing”,这些会自动放在流范围内,因此您可以直接在JSP中引用它们,如${user.firstname}。)

© www.soinside.com 2019 - 2024. All rights reserved.