Carlos Schuldiner Carlos Schuldiner - 1 year ago 76
Java Question

Script tag not working

I am creating an application using spring and tiles. I have a general template where all the js and css are loaded. Anyway, there are some script that are only needed on some views, so I put them only where I need them. But it doesn't work

there are some code



<definition name="template.general" template="/WEB-INF/view/templates/general.jsp">
<put-list-attribute name="styles">
<add-attribute value="/media/css/materialize.css" />
<add-attribute value="/media/css/style.css" />
<add-attribute value="/media/css/custom-style.css" />
<put-list-attribute name="scripts">
<add-attribute value="/media/js/jquery-1.11.2.min.js" />
<add-attribute value="/media/js/materialize.js" />
<add-attribute value="/media/js/plugins/perfect-scrollbar.min.js" />
<add-attribute value="/media/js/plugins.js" />


<%@ taglib uri="" prefix="tiles"%>
<%@ taglib prefix="s" uri=""%>
<%@ taglib prefix="c" uri=""%>

<tiles:importAttribute name="styles"/>
<tiles:importAttribute name="scripts"/>
<tiles:importAttribute name="page_scripts" ignore="true"/>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

<c:forEach var="css" items="${styles}">
<link rel="stylesheet" type="text/css" href="<c:url value="${css}"/>" media="screen,projection">

<c:forEach var="script" items="${scripts}">
<script src="<c:url value="${script}"/>"></script>

<c:forEach var="script" items="${page_scripts}">
<script src="<c:url value="${script}"/>"></script>


<div id="main">
<div class="wrapper">
<section id="content">
<tiles:insertAttribute name="body" />



<definition name="solution/list" extends="template.general">
<put-attribute name="body" value="/WEB-INF/view/solution/list.jsp" />
<put-list-attribute name="page_scripts">
<add-attribute value="/media/js/plugins/jquery.dataTables.js" />


<%@ taglib prefix="c" uri=""%>

<table id="solutionList" class="responsive-table display" cellspacing="0">

<c:forEach var="solution" items="${solutions}">

responsive : true

why when I run this application the script in list.jsp doesn't load? also, chrome devtools marks the line with 'failed to load resource: the server responded with a status of 404'.

Answer Source

I think and see you didn't select the table

you don't have # in $('solutionList').dataTable({ responsive : true });

so correct to $('#solutionList').dataTable({ responsive : true });