Announcement Announcement Module
Collapse
No announcement yet.
JavaScript will only load if located in /static Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • JavaScript will only load if located in /static

    Hi,

    I'm coming across a problem when using Spring Security with JavaScript or CSS files.

    I have a project I am building with Maven and have the following structure:

    /static
    /jsapp
    /login.jsp
    /index.jsp

    I use the standard login from spring security and that works fine. The problem occurs when index.jsp loads and pulls in a JS file from the /jsapp folder. The file appears to have the content of the index.jsp instead of it's actual content.

    Now, if I move the /jsapp to sit under /static, it works perfectly!

    Is there a requirement for all JS files (and similar) to sit under the /static folder? If so, is there a way around this? Can I store JS files in a folder which is not the /static one?

    Thanks,
    Ale

  • #2
    you can place js/css to any folder, just make sure that its filter="none" is there.

    Comment


    • #3
      Hi Rohan, thanks for the response. Setting filters to none is essentially the same as setting security to none in the <http> tag.

      I'd like to maintain the files in jsapp with security.

      To maintain security, the folder needs to be under static or it won't server the JS correctly.

      On a side note, filters is deprecated with version 3.1

      Comment


      • #4
        Found out how to fix this issue. I added the following to the web.xml:

        Code:
        	<servlet-mapping>
        		<servlet-name>default</servlet-name>
        		<url-pattern>/static/*</url-pattern>
        		<url-pattern>/myfolder/*</url-pattern>
        		<url-pattern>/myotherfolder/*</url-pattern>
        	</servlet-mapping>

        Comment

        Working...
        X