На самом деле я пытаюсь получить доступ к моей полной службе отдыха на основе весны, я не настраиваю DispatcherServlet в web.xml, вместо этого я использую ContxtLoaderListener для загрузки моего конфигурационного файла весны.Доступ к службе весеннего отдыха без диспетчерского сервлета
Из моих журналов я вижу, что моя служба получает инициализацию, когда я когда-либо обращаюсь к указанному выше URL-адресу, ICallServlet получает запрос, поскольку он имеет url-шаблон как '/ *' (это я не могу изменить).
Здесь моя проблема в том, что я не смог получить доступ к моему сервису, запрос не доходит до моего обслуживания. без использования DispatcherServlet есть ли способ вызвать мой сервис отдыха, кто-то, пожалуйста, помогите мне решить эту проблему.
У меня есть контроллер отдыха:
package mypackage; @RestController @RequestMapping("/api/casaOnboarding") public class CasaOnboardingRestService { @ResponseBody @RequestMapping(value="/pwebXML", method=RequestMethod.POST, consumes={"application/json", "application/xml"}) public ResponseEntity pwebXML(@RequestBody OnboardingReq onboardingReq, HttpServletRequest request, HttpServletResponse response){ System.out.println("Request Reached"); ---- } }
web.xml (Нет Dispatcher Servlet)
<?xml version="1.0" encoding="UTF-8"?> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath*:controllerServiceContext.xml</param-value> </context-param> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <servlet> <servlet-name>iCallUI</servlet-name> <servlet-class>com.ui.ICallServlet</servlet-class> </servlet> <servlet-mapping> <servlet-name>iCallUI</servlet-name> <url-pattern>/*</url-pattern> </servlet-mapping>
controllerServiceContext.xml
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context" xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:task="http://www.springframework.org/schema/task" xsi:schemaLocation=" http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.1.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-3.1.xsd"> <context:annotation-config /> <context:component-scan base-package="mypackage"/> <task:annotation-driven /> </beans>
Log File
10:45:41,643 DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] (ServerService Thread Pool -- 62) Creating shared instance of singleton bean 'casaOnboardingRestService' 10:45:41,643 DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] (ServerService Thread Pool -- 62) Creating instance of bean 'casaOnboardingRestService' 10:45:41,643 DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] (ServerService Thread Pool -- 62) Eagerly caching bean 'casaOnboardingRestService' to allow for resolving potential circular references 10:45:41,643 DEBUG [org.springframework.beans.factory.support.DefaultListableBeanFactory] (ServerService Thread Pool -- 62) Finished creating instance of bean 'casaOnboardingRestService'
URL: http://localhost:8080/icall-ui/api/casaOnboarding/pwebXML
есть ли способ я могу выполните поведение DispatcherServlet с моим ICallServlet, добавив часть кода для пересылки запроса на мою услугу. – Uppicharla
Если я использую DiapatcherServlet, то какой шаблон url мне нужно указать, так как ICallServlet использует url-шаблон '/ *', все запросы будут захвачены ICallServlet. Какой url-шаблон позволяет DispatcherServlet обрабатывать мой запрос. – Uppicharla
Если нет явных требований, вы можете попробовать использовать Джерси. Это легко и просто. – user2004685