springmvc,使用@RequestMapping定义的URL访问不到方法
WEB.XML:<!--SpringMVC核心控制器--><servlet><servlet-name>dispatcher</servlet-name><servlet...
WEB.XML:
<!-- Spring MVC 核心控制器 --> <servlet> <servlet-name>dispatcher</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value> classpath:spring-controller.xml </param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>dispatcher</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping>
spring-controller.xml:
<!-- 启用spring mvc 注解 --> <context:annotation-config /> <mvc:default-servlet-handler/> <!--使Spring支持自动检测组件,如注解的Controller --> <context:component-scan base-package="com.tisson.vcinterface.controller"/> <context:component-scan base-package="com.tisson.vcinterface.service"/> <context:component-scan base-package="com.tisson.vcinterface.dao"/>
<!-- 启动 Spring MVC 的注解功能,完成请求和注解 POJO 的映射 --> <bean id="handlerMapping" class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping" /> <bean id="handlerAdapter" class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"/>
代码:
访问URL:http://172.16.25.175:8080/vc_interface/calloutData/dataReceive
使用:http://172.16.25.175:8080/vc_interface/可打开项目 展开
<!-- Spring MVC 核心控制器 --> <servlet> <servlet-name>dispatcher</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value> classpath:spring-controller.xml </param-value> </init-param> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>dispatcher</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping>
spring-controller.xml:
<!-- 启用spring mvc 注解 --> <context:annotation-config /> <mvc:default-servlet-handler/> <!--使Spring支持自动检测组件,如注解的Controller --> <context:component-scan base-package="com.tisson.vcinterface.controller"/> <context:component-scan base-package="com.tisson.vcinterface.service"/> <context:component-scan base-package="com.tisson.vcinterface.dao"/>
<!-- 启动 Spring MVC 的注解功能,完成请求和注解 POJO 的映射 --> <bean id="handlerMapping" class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping" /> <bean id="handlerAdapter" class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"/>
代码:
访问URL:http://172.16.25.175:8080/vc_interface/calloutData/dataReceive
使用:http://172.16.25.175:8080/vc_interface/可打开项目 展开
- 你的回答被采纳后将获得:
- 系统奖励15(财富值+成长值)+难题奖励20(财富值+成长值)
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询