Springmvc @PathVariable ("B") double b loss accuracy problem

Source: Internet
Author: User

Spring MVC supports rest from 3.0, mainly through @pathvariable to handle the mapping of request parameters and paths.
Due to the reasons for the SEO, many people like the name of the news as part of the path to deal with, when the Chinese name will encounter problems, no way to map, this is because of coding problems, as long as the tomcat/conf to find Server.xml, add uriencoding= " UTF-8 "The URL encoding setting will solve the Chinese problem.
Also often encountered in the path a little ".", and the point is a special character, such as. html,. Do and so on, so spring MVC by default is to put the information behind the point as a file suffix, this time we need to modify this default value.

<bean class= "Org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping" >
<property name= "interceptors" ref= "Localechangeinterceptor"/>
<property name= "Usedefaultsuffixpattern" value= "false"/>
</bean>

In addition, this time if only set this, the request can be passed to the controller, but pass the data will be a problem, only the last point of the data, unless you add "/" at the end, such as the/news/test. Point/This will be "test. Point" as a whole, or will only get " Test ". At this time we can set @requestmapping ("/news/{title:.*}")
That's all OK.

Springmvc @PathVariable ("B") double b loss accuracy problem

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.