Most recently, I began to learn Java, at the end of the course I was given the task to write a small (in comparison with the company's projects) training project. When I was told about spring, namely about context.xml, to the question, what is here and how:

<beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc" xsi:schemaLocation="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/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd"> 

they answered me: it will be like this everywhere, forget it! So, now, I need to add to my AJAX project, I took an example from here , run it, it has earned. I try to do the same in my project, it does not work (The difference between projects, only in these xml.

My mvc-dispatcher-servlet.xml

 <beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc" xsi:schemaLocation="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/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd"> <context:component-scan base-package="com.luxoft.buying_currency.controllerUI" /> <!--<mvc:annotation-driven />--> <!--<mvc:resources mapping="/**" location="/" />--> <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix"> <value>/WEB-INF/pages/</value> </property> <property name="suffix"> <value>.jsp</value> </property> </bean> 

servlet-context.xml from example

 <?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" xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.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/" /> <!-- Resolves views selected for rendering by @Controllers to .jsp resources in the /WEB-INF/views directory --> <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.blogspot.alexeydl" /> </beans:beans> 

Naturally, I change everything in the second xml for my own, insert it into my project, my project stops working, I leave my xml not working AJAX. My project

How to solve this problem? I don’t have much time to read about contxt.xml, I didn’t find it on the first links in Google.

  • and if you uncompress <mvc:annotation-driven /> will it work? - Mikhail Vaysman
  • then my program stops working - sanchopa
  • any mistakes? and without this line everything works? - Mikhail Vaysman
  • If you uncomment this line ... then the session falls off. The program works first, but when I try to access the object that I receive from the session, the program does not work. nullpointerexception - sanchopa

0