A game connection that used to be sworn enemies.
Happened a lot, uh, a lot.
And now suddenly I find something very interesting.
http://221.130.15.57:8091/p?p_E/2035847_4d8b002b_bccc45a6/
Connection encryption, filter fix
But
There are wooden extensions. There's wood?
RESTful URL
is to meet the rest standards when designing URLs, rest standards ... I can't say for sure,
can refer to Http://baike.baidu.com/view/1077487.htm?fr=ala0_1
Spring is so hard to say that it's going to be bloated into God's horse stuff .... Concise and concise.
Because the next version of Rapid-framwork needs to integrate the spring RESTful URL, I've studied how to build it. and ran into a problem.
SPRINGMVC 3.0 adds the RESTful URL feature and constructs a URL similar to the Javaeye present. Rest introduction, and here's an article on struts2 rest construction: Using Struts 2 to develop RESTful services
A simple example is as follows, such as the following URL
Java code
/BLOG/1 HTTP get => gets id = 1 Blog
/BLOG/1 HTTP Delete => Delete id = 1 Blog
/BLOG/1 HTTP put => update id = 1 Blog
/blog HTTP POST => New Blog
/BLOG/1 HTTP get => gets id = 1 Blog
/BLOG/1 HTTP Delete => Delete id = 1 Blog
/BLOG/1 HTTP put => update id = 1 Blog
/blog HTTP POST => New Blog
Here's a detailed solution for spring rest use.
First, we look at this article with three questions below.
1. How to restful URLs without extensions in Java constructs, such as/FORMS/1, instead of/forms/1.do
2. Since we want to construct a URL that does not have an extension to handle a container mapping of static resources, it is now occupied by our spring, how is the conflict resolved?
3. The browser's form label does not support submitting Delete,put requests, how to solve the curve?
Springmvc Rest Implementation
The Resturl of SPRINGMVC is provided through @requestmapping and @pathvariable annotation, through such as @requestmapping (value= "/blog/{id}", method= Requestmethod.delete) to handle the/BLOG/1 DELETE request.
Java code
@RequestMapping (value= "/blog/{id}", Method=requestmethod.delete)
Public Modelandview Delete (@PathVariable Long id,httpservletrequest request,httpservletresponse response) {
Blogmanager.removebyid (ID);
return new Modelandview (list_action);
}
@RequestMapping (value= "/blog/{id}", Method=requestmethod.delete)
Public Modelandview Delete (@PathVariable Long id,httpservletrequest request,httpservletresponse response) {
Blogmanager.removebyid (ID);
return new Modelandview (list_action);
}
@RequestMapping @PathVariable If the URL has parameters, it is used in conjunction with the
Java code
@RequestMapping (value= "/blog/{blogid}/message/{msgid}", Method=requestmethod.delete)
Public Modelandview Delete (@PathVariable ("BlogId") long blogId, @PathVariable ("MsgId") long msgid,httpservletrequest Request,httpservletresponse response) {
}
@RequestMapping (value= "/blog/{blogid}/message/{msgid}", Method=requestmethod.delete)
Public Modelandview Delete (@PathVariable ("BlogId") long blogId, @PathVariable ("MsgId") long msgid,httpservletrequest Request,httpservletresponse response) {
}
Spring Rest Configuration Guide
1. SPRINGMVC web.xml Configuration
XML code
<!--the servlet provides for containers such as tomcat,jetty, mapping static resources from/to/static/directories, such as the original Access Http://localhost/foo.css, now http://localhost/ Static/foo.css-->
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>/static/*</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>springmvc</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<!--URL Rewrite filter to convert access to static resource http://localhost/foo.css to Http://localhost/static/foo.css-->
<filter>
<filter-name>UrlRewriteFilter</filter-name>
<filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>
<init-param>
<param-name>confReloadCheckInterval</param-name>
<param-value>60</param-value>
</init-param>
<init-param>
<param-name>logLevel</param-name>
<param-value>DEBUG</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>UrlRewriteFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!--overwrite the default servlet/, the SPRINGMVC servlet will handle mappings that originally handled static resources-->
<servlet-mapping>
<servlet-name>springmvc</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<!--browsers do not support Put,delete methods, which convert/blog?_method=delete to the standard HTTP Delete method-->
<filter>
<filter-name>HiddenHttpMethodFilter</filter-name>
<filter-class>org.springframework.web.filter.HiddenHttpMethodFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>HiddenHttpMethodFilter</filter-name>
<servlet-name>springmvc</servlet-name>
</filter-mapping>
<!--the servlet provides for containers such as tomcat,jetty, mapping static resources from/to/static/directories, such as the original Access Http://localhost/foo.css, now http://localhost/ Static/foo.css-->
<servlet-mapping>
<servlet-name>default</servlet-name>
<url-pattern>/static/*</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>springmvc</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<!--URL Rewrite filter to convert access to static resource http://localhost/foo.css to Http://localhost/static/foo.css-->
<filter>
<filter-name>UrlRewriteFilter</filter-name>
<filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>
<init-param>
<param-name>confReloadCheckInterval</param-name>
<param-value>60</param-value>
</init-param>
<init-param>
<param-name>logLevel</param-name>
<param-value>DEBUG</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>UrlRewriteFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!--overwrite the default servlet/, the SPRINGMVC servlet will handle mappings that originally handled static resources-->
<servlet-mapping>
<servlet-name>springmvc</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<!--browsers do not support Put,delete methods, which convert/blog?_method=delete to the standard HTTP Delete method-->
<filter>
<filter-name>HiddenHttpMethodFilter</filter-name>
<filter-class>org.springframework.web.filter.HiddenHttpMethodFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>HiddenHttpMethodFilter</filter-name>
<servlet-name>springmvc</servlet-name>
</filter-mapping>
2. Webapp/web-inf/springmvc-servlet.xml configuration, use the following two class to activate @requestmapping annotation
Java code
<bean class= "org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"/>
<bean class= "Org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"/>
<bean class= "org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"/>
<bean class= "Org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"/>
Full configuration
Java code
<beans default-autowire= "ByName" >
<!--automatic search for @controller annotation class-->
<context:component-scan base-package= "Com.**.controller"/>
<bean class= "org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"/>
<bean class= "Org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"/>
<!--Default Viewresolver-->
<bean id= "Viewresolver" class= "Org.springframework.web.servlet.view.InternalResourceViewResolver" >
<property name= "Viewclass" value= "Org.springframework.web.servlet.view.JstlView"/>
<property name= "prefix" value= "/pages"/>
<property name= "suffix" value= ". JSP" ></property>
</bean>
<bean id= "Messagesource" class= "Org.springframework.context.support.ResourceBundleMessageSource" I18n/messages "/>
<!--Mapping exception to the handler view-->
<bean id= "Exceptionresolver" class= "Org.springframework.web.servlet.handler.SimpleMappingExceptionResolver" >
<!--to/commons/error.jsp-->
<property name= "Defaulterrorview" value= "/commons/error"/>
<property name= "Exceptionmappings" >
<props>
</props>
</property>
</bean>
</beans>
=========================
The feeling is very useful for dynamic encryption this extension protection ....
When Tomcat resin is busy, he's going to get a message.
Hey, stupid folk. Seemingly useless, huh?