java prohibits direct url access to images

*. Since the project needs to inquire about the problem of prohibiting direct access to image resources through url links in many ways, after trying several solutions, an available resource is found.

     

Mainly the use of the refer parameter in the request
When accessing static resources directly through url, refer is null
When a static resource is called through the system, the refer is the link to the caller
Therefore: You can judge whether it is an operation to directly access the image link by judging the refer

 

*, the realization of ideas

The first is a filter, which specifically intercepts the specified file type or path
Determine whether the refer is valid in the filter
If it is valid, continue, otherwise jump to the error page.

 

 *, Little knowledge of forbidden pictures right click

<script type="text/javascript">
	$(function() {
		$("img").load(function() {//Make sure that the image has been loaded, otherwise the image will not be loaded and the event will be invalid
		    $('img').bind("contextmenu", function(e){return false; });
		});
	});
</script>

 

 

 

 

 

-------------------------------------------------- -----------resource-------------------------------------- ---------------------

*, prevent image hotlinking

http://blog.csdn.net/u014482758/article/details/43485787

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326236193&siteId=291194637