About the JSP file under SPRINGMVC framework access Web-inf

Source: Internet
Author: User

Problem: The SPRINGMVC framework accesses the JSP file under Web-inf, as follows: Using SPRINGMVC, you will typically use the Springmvc view resolver, which is probably configured

<property name= "prefix" value= "/web-inf/jsp/" ></property><property name= "suffix" value= ". jsp" > </property>

When my control returns

return new Modelandview ("Admin/index");   

The actual access is/web-inf/jsp/admin/index.jsp this page, then placed under Web-inf can only be accessed by the server to ensure security. If there is such a code in INDEX.JSP

, top.jsp and index.jsp are all in the admin directory, so access to index will be 404.

At this time tangled: 1, top.jsp if must and index.jsp in the same directory, will add a control, add a control for a connection is not worth. 2, if not in the same directory under the Webroot root directory, index.jsp and top.jsp is not the same place, maintenance time is not very convenient, 3, another situation SPRINGMVC view parser path modified to <property name= "prefix "Value="/jsp/"></property> is in the project root directory, so that the client can also directly access this directory, there is no security, how to do it?

The following solutions are available through Internet collation:

=================1 Building =====================

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

=================2 Building =====================

What I did was--I had to add a controller. The idea is to do the following

[List=1]

    • Get a directory of publicly available JSPs, such as/web-inf/jsp/public.
    • There's a control,spring, and there's a redirect. or write yourself a. Inside fixed to the top of the catalogue. Of course, it can be implemented with flexible points such as parameter configuration.

Become

Like this.

[/list]

The purpose of doing this is basically to answer your question.

1. JSP Unified put together--/web-inf/jsp/.

2. Use one and only one controller to control the JSP that needs to be exposed.

About the JSP file under SPRINGMVC framework access Web-inf

Related Article

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.