Java Spring MVC路径变量区分大小写问题
我有一个Spring MVC Java web应用程序。我有以下控制器Java Spring MVC路径变量区分大小写问题,java,spring,spring-mvc,path-variables,Java,Spring,Spring Mvc,Path Variables,我有一个Spring MVC Java web应用程序。我有以下控制器 @RequestMapping(value = "/{service}/list", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseBody public ResultData getList(@PathVariable String service, @RequestBody QueryD
@RequestMapping(value = "/{service}/list", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public ResultData getList(@PathVariable String service,
@RequestBody QueryData queryData, HttpServletRequest request) {
//controller code
return response;
}
我的applicationContext.xml中有以下内容
在前端,我尝试使用AJAX调用调用控制器。问题是一些URL正在工作,而另一个URL发出400个错误请求,并且客户端发送的请求语法错误。我尝试在Mozilla中使用RESTClient进行连接
如果URL是
/应用程序/列表-状态为200 OK
/业务/列表-状态为200 OK
/业务功能/列表-状态为200 OK
/业务功能/列表-状态为400错误请求
/工具技术/列表-状态为400错误请求
/工具技术/列表-状态为200 OK
前两个还可以。但是3和4,一个字母是大写的,在第4位,它不需要。
即使我尝试businessfffunction,它也会在大写字母f之前添加额外的f
第五和第六节。我想寄第五箱。也就是说,都是小写的,不起作用。但如果我尝试第六,它的工作
为什么会这样?我怎样才能解决这个问题
谢谢。控制器代码中是否会出现异常?控制器中不会出现异常$00 Bad request表示“客户端发送的请求在语法上不正确”。这就是问题所在。由于这种情况,映射到该控制器时出现问题。我不明白问题出在哪里您是否有另一个控制器映射到URL/businnesFunction?如果是这种情况,Spring将尝试在该控制器中查找/businessFunction/list。换句话说,请确保{service}名称与任何其他请求映射的URL不冲突。我没有任何。我有一个URL,但那只是/businnesFunction'而不是/businnesFunction/list`。所以两者都不同,对吗?对于工具技术,我没有任何其他映射。
<!-- Activates scanning of @Autowired -->
<context:annotation-config />
<context:component-scan base-package="some package" />
<mvc:annotation-driven />
<bean id="localeChangeInterceptor"
class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
<property name="paramName" value="lang" />
</bean>
<bean id="localeResolver"
class="org.springframework.web.servlet.i18n.CookieLocaleResolver">
<property name="defaultLocale" value="en" />
</bean>
<bean id="handlerMapping"
class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping">
<property name="interceptors">
<ref bean="localeChangeInterceptor" />
</property>
</bean>
<bean id="multipartResolver"
class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<property name="maxUploadSize" value="32771748" />
</bean>
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/" />
<property name="suffix" value=".jsp" />
</bean>