Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring @SessionAttributes unknown中的我的表单bean_Spring_Spring Mvc - Fatal编程技术网

Spring @SessionAttributes unknown中的我的表单bean

Spring @SessionAttributes unknown中的我的表单bean,spring,spring-mvc,Spring,Spring Mvc,我有一个表单bean,我想将其存储在会话中,因此在包含欢迎处理程序的控制器中,我放置了以下内容: @Controller @SessionAttributes({"searchcontact","cities"}) 我的表格: <form:form modelAttribute="searchcontact" ... > ... <form:options items="${cities}" itemValue="id" itemLabel="name" /> 可

我有一个表单bean,我想将其存储在会话中,因此在包含欢迎处理程序的控制器中,我放置了以下内容:

@Controller
@SessionAttributes({"searchcontact","cities"})
我的表格:

<form:form modelAttribute="searchcontact"  ... >
...
<form:options  items="${cities}" itemValue="id" itemLabel="name" />

可以在所有会话中访问城市属性。

@SessionAttributes
。它用于在给定控制器的请求之间存储数据


要在会话中存储数据以供其他控制器访问,请使用
HttpSession.setAttribute()

非真读,将
@SessionAttributes
中的数据添加到会话中(
HttpSession
)它可能会向HttpSession添加数据,但其目的是在特定控制器对话的上下文中使用。您可以发布呈现“searchcontact”表单的控制器代码吗?我在每个jsp页面中都加载了一个搜索部分,我发现了问题的来源->我在请求中复制的
searchcontact
,但我的控制器的处理程序由
@SessionAttributes({“searchcontact”,“cities”)注释
在其他控制器中,甚至bean
searchcontact
都存储在session中,spring或jsp进程在请求中查找他,但没有找到他。
Etat HTTP 500 - java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'searchcontact' available as request attribute