gpt4 book ai didi

java - Spring Webflow org.springframework.expression.spel.SpelEvaluationException : EL1009E - cannot be set on null

转载 作者:行者123 更新时间:2023-12-01 14:38:02 32 4
gpt4 key购买 nike

我的代码:

类别-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-2.0.xsd">

<var name="flowScope.categories" class="events.ui.web.adminweb.flow.CategoryFormBackingObject"/>

<view-state id="categoryOverview" model="categories" view="categoryOverview.jsp">
<on-entry>
<evaluate expression="categoryFacade.getCategories()" result="flowScope.categories.categories"/>
</on-entry>
<transition on="new" to="newCategory" />
<transition on="edit" to="editCategory">
<evaluate expression="categoryFacade.getCategoryById(requestParameters.cid)" result="flowScope.categories.editableCategory" />
</transition>
<transition on="delete" to="deleteCategory">
<evaluate expression="categoryFacade.getCategoryById(requestParameters.cid)" result="flowScope.categories.editableCategory" />
</transition>
</view-state>

[...]

DefaultCategoryFacade.java

@Component("categoryFacade")
public class DefaultCategoryFacade implements CategoryFacade {

@Resource
private CategoryService categoryService;
@Resource
private CategoryConverter categoryConverter;

@Override
public Collection<CategoryData> getCategories() {
return categoryConverter.convertAll(categoryService.getCategories());
}

@Override
public CategoryData getCategoryById(int id) {
return categoryConverter.convert(categoryService.getCategoryById(id));
}
}

CategoryFormBackingObject.java

public class CategoryFormBackingObject implements Serializable {

private static final long serialVersionUID = -8237671561218547425L;

private List<CategoryData> categories = new ArrayList<CategoryData>();
private CategoryData editableCategory = new CategoryData();
//With getters and setters

CategoryData.java

public class CategoryData implements Serializable {

private static final long serialVersionUID = 2706910537987564159L;

private int id;
private String name;
// With getters and setters

这是我的异常(exception):

 Servlet.service() for servlet [adminweb] in context with path [/adminweb] threw exception [Request processing failed; nested exception is org.springframework.webflow.execution.ActionExecutionException: Exception thrown executing [AnnotatedAction@37c390b8 targetAction = [EvaluateAction@8523ca2 expression = categoryFacade.getCategories(), resultExpression = flowScope.categories.categories], attributes = map[[empty]]] in state 'categoryOverview' of flow 'categories' -- action execution attributes were 'map[[empty]]'] with root cause
org.springframework.expression.spel.SpelEvaluationException: EL1009E:(pos 21): Field or property 'categories' cannot be set on null

"new" View 状态中的 flowScope.categories.editableCategory 也会发生同样的情况。这里出了什么问题,我不知道!

最佳答案

您必须在 Bean 名称前添加字符 @ 前缀

<evaluate expression="@categoryFacade.getCategories()"

这样就可以了。

关于java - Spring Webflow org.springframework.expression.spel.SpelEvaluationException : EL1009E - cannot be set on null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16296081/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com