Hello guys I have big problem here. Sessions in my controller are not working right. My goal is to have one comp object for each session but I get every time the same comp (comp is initialized just once and not per session).
Example:
Mozilla: Firstly my comp is null. When in one screen I select one comp, new comp is initialized and everything is OK.
Chrome: When I get to the screen where I want to select my comp is already initialized (Mozilla comp) so when I select my comp, comp from mozilla is overridden.
Controller :
package com.test;
@SessionAttributes({"comp", "userDetails"})
@Controller
@RequestMapping(value="/arep")
public class ARepController{
@Autowired AdmUserDetails userDetails;
@Autowired
private ARepService aRepService;
@Autowired
private Component comp;
}
Component:
package com.test;
@Component
@Scope(proxyMode = ScopedProxyMode.TARGET_CLASS, value = "session")
public class Component implements Serializable {
private static final long serialVersionUID = 587780902400791285L;
private List<Component Item> items = new ArrayList<ComponentItem>();
private Integer length;
private Integer height;
private Integer depth;
public Component () {
}
public Component (Integer length, Integer height,Integer depth) {
this.length = length;
this.height = height;
this.depth = depth;
}
}
root-context.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://ift.tt/GArMu6"
xmlns:xsi="http://ift.tt/ra1lAU"
xmlns:context="http://ift.tt/GArMu7"
xmlns:tx="http://ift.tt/OGfeU2"
xmlns:aop="http://ift.tt/OpNdV1"
xsi:schemaLocation="http://ift.tt/GArMu6 http://ift.tt/1jdM0fG
http://ift.tt/GArMu7 http://ift.tt/1jdLYo7
http://ift.tt/OGfeU2 http://ift.tt/1ePwvbN
http://ift.tt/OpNdV1 http://ift.tt/1iMF6wJ" >
<tx:annotation-driven/>
<context:component-scan base-package="com.test" >
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
</context:component-scan>
</beans>
servlet-context.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://ift.tt/1bHqwjR"
xmlns:xsi="http://ift.tt/ra1lAU"
xmlns:beans="http://ift.tt/GArMu6"
xmlns:context="http://ift.tt/GArMu7"
xsi:schemaLocation="http://ift.tt/1bHqwjR http://ift.tt/1fmimld
http://ift.tt/GArMu6 http://ift.tt/1jdM0fG
http://ift.tt/GArMu7 http://ift.tt/1jdLYo7">
<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.InternalResourceViewResolver">
<beans:property name="prefix" value="/WEB-INF/views/" />
<beans:property name="suffix" value=".jsp" />
</beans:bean>
<context:component-scan base-package="com.test" use-default-filters="false">
<context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
</context:component-scan>
</beans:beans>
I copied just the code that seemed crucial to me. In advance I would like to thank anyone who will take his time for helping me out here.
No comments:
Post a Comment