ninja-core/src/main/java/ninja/AssetsController.java
private URL getStaticFileFromAssetsDir(String fileName) {

        URL url = null;

        if (ninjaProperties.isDev() 
                // Testing that the file exists is important because
                // on some dev environments we do not get the correct asset dir
                // via System.getPropery("user.dir").
                // In that case we fall back to trying to load from classpath
                && new File(assetsDirInDevModeWithoutTrailingSlash()).exists()) {
            String finalNameWithoutLeadingSlash = assetsControllerHelper.normalizePathWithoutLeadingSlash(fileName, false);
            File possibleFile = new File(
                    assetsDirInDevModeWithoutTrailingSlash() 
                            + File.separator 
                            + finalNameWithoutLeadingSlash);
            url = getUrlForFile(possibleFile);
        } else {
            String finalNameWithoutLeadingSlash = assetsControllerHelper.normalizePathWithoutLeadingSlash(fileName, true);
            url = this.getClass().getClassLoader()
                    .getResource(ASSETS_DIR
                                 + "/"
                                 + finalNameWithoutLeadingSlash);
        }

        return url;
    }
private URL getStaticFileFromAssetsDir(String fileName) {

        URL url = null;

        if (ninjaProperties.isDev() 
                // Testing that the file exists is important because
                // on some dev environments we do not get the correct asset dir
                // via System.getPropery("user.dir").
                // In that case we fall back to trying to load from classpath
                && new File(assetsDirInDevModeWithoutTrailingSlash()).exists()) {
            String finalNameWithoutLeadingSlash = assetsControllerHelper.normalizePathWithoutLeadingSlash(fileName, false);
            File possibleFile = new File(
                    assetsDirInDevModeWithoutTrailingSlash() 
                            + File.separator 
                            + finalNameWithoutLeadingSlash);
            url = getUrlForFile(possibleFile);
        } else {
            String finalNameWithoutLeadingSlash = assetsControllerHelper.normalizePathWithoutLeadingSlash(fileName, true);
            url = this.getClass().getClassLoader()
                    .getResource(ASSETS_DIR
                                 + "/"
                                 + finalNameWithoutLeadingSlash);
        }

        return url;
    }
private URL getStaticFileFromAssetsDir ( String fileName ) { URL url = null ; if ( ninjaProperties . isDev ( ) // Testing that the file exists is important because // on some dev environments we do not get the correct asset dir // via System.getPropery("user.dir"). // In that case we fall back to trying to load from classpath && new File ( assetsDirInDevModeWithoutTrailingSlash ( ) ) . exists ( ) ) { String finalNameWithoutLeadingSlash = assetsControllerHelper . normalizePathWithoutLeadingSlash ( fileName , false ) ; File possibleFile = new File ( assetsDirInDevModeWithoutTrailingSlash ( ) + File . separator + finalNameWithoutLeadingSlash ) ; url = getUrlForFile ( possibleFile ) ; } else { String finalNameWithoutLeadingSlash = assetsControllerHelper . normalizePathWithoutLeadingSlash ( fileName , true ) ; url = this . getClass ( ) . getClassLoader ( ) . getResource ( ASSETS_DIR + "/" + finalNameWithoutLeadingSlash ) ; } return url ; }
Loads files from assets directory. This is the default directory
of Ninja where to store stuff. Usually in src/main/java/assets/.
Loads files from assets directory . This is the default directory of Ninja where to store stuff . Usually in src / main / java / assets / .