SPRINGMVC Special study précis-writers-digression

Source: Internet
Author: User

1.Ant-style request mapping


2.Rest Style


Increase (POST) Delete (delete) change (PUT) Check (GET)

but a label or form form, all only post, get two kinds of requests

So : Introduce Hiddenhttpmethodfilter filters to filter all requests:

GET Request---> Continue execution

POST Request---> Find out if there is a parameter named "_method" in the pass. There is no post execution, and there is a request in accordance with the parameters of the communication.

Put request:

<form>
	<input type= "hidden" name= "_method" value= "PUT"/>
	<input type= "text" name= "id" value = "/>
" ... </form>

Delete request:

<form>
	<input type= "hidden" name= "_method" value= "DELETE"/>
	<input type= "text" Name= "id" Value= "/>
" ... </form>

Configure the Hiddenhttpmethodfilter filter in Web. xml:

<filter>
<filter-name>hiddenHttpMethodFilter</filter-name>
<filter-class> org.springframework.web.filter.hiddenhttpmethodfilter</filter-class> 
</filter>
< filter-mapping>
<filter-name>hiddenHttpMethodFilter</filter-name>
<url-pattern>/* </url-pattern>
</filter-mapping>

3.Servlet API


Background Request Method:

@RequestMapping (value= "...") Public
String test (httpservletrequest request,httpservletresponse response) {
	return "Success";
}

4.SPRINGMVC Internationalization:

1. The foreground JSP writes:



2.springmvc.xml in configuration: (Note id= "Messagesource")


Notes:


5. Some request mappings directly jump to the page, do not need to go backstage request Java code

You can directly configure the map to Physical view page in Springmvc.xml, such as: request/ABCDEFG jump directly to aa.jsp

<mvc:view-controller path= "/ABCDEFG" view-name= "AA"/>

<!--precautions: in Springmvc.xml

If a <mvc:view-controller>! is configured for a mapping
The other controller methods will fail ...
So configure the <mvc:annotation-driven> again, and make the other controller methods valid:

-

<mvc:view-controller path= "/ABCDEFG" view-name= "AA"/>
<mvc:annotation-driven></mvc: Annotation-driven>
<mvc:view-controller>, <mvc:annotation-driven> to appear in pairs.

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.