SpringMVC POST亂碼和restful

POST亂碼須要在 web.xml裏面設置一個filterhtml

配置以下:java

<!-- 設置一個filter -->
  <filter>
    <filter-name>CharacterEncodingFilter</filter-name>
    <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
    <init-param>
              <param-name>encoding</param-name>
              <param-value>utf-8</param-value>
    </init-param>
  </filter>
  <!-- 配置filter -->
  <filter-mapping>
    <filter-name>CharacterEncodingFilter</filter-name>
    <url-pattern>*.html</url-pattern>
  </filter-mapping>

restful

//|RestFull
	@RequestMapping("/delete/{id}")
	public String hello3(@PathVariable int id)
	{
		System.out.println(id);
		return "index.jsp";
	}
訪問 http://localhost::8080/delete/1.html,此時傳入的就是 1
相關文章
相關標籤/搜索