0

I work with Spring MVC. I have a dynamic web project Eclipse

Structure folder is

enter image description here

I have the following jsp actualizarCorreo.jsp

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<!DOCTYPE html>
<html>
<head>
<title>EusurveyAdmin menu princiapl</title>

<script type="text/javascript" src="/resources/js/properties.js"></script>

<script type="text/javascript">
function pruebaB()
{
   alert('en prueba');
}
</script>
</head>
<body>
    <c:set var="pageNumber" value="${pageNumber}" />
    <table class="actualizarCorreos">

        <tbody>
        <a href="#" onclick="prueba()"; return false;">
            <input type="radio" onclick="prueba()" class="check" id="id1"
                name="id1" value="true" />
            <spring:message code="label.ModificarCorreos" />



        </tbody>
    </table>

</body>

In this jsp I load another js

<script type="text/javascript" src="/resources/js/properties.js">

This js is the path WebContent/resources/js.

properties.js is

alert('cargado properties');
function checkConfirmationPage()
{       
    alert('en check');
    if ($("#conflink").is(":checked"))
    {} else {};
}

function prueba()
{
    alert('en prueba');
}

I call function prueba from actualizarCorreo.jsp when a radio button is clicked

<input type="radio" onclick="prueba()" class="check" id="id1"
                name="id1" value="true" />
            <spring:message code="label.ModificarCorreos" />

I don't see the alert message function prueba.

What is it wrong?

Carlota
  • 1,239
  • 3
  • 29
  • 59

2 Answers2

0

Try this

 <script type="text/javascript" src="../resources/js/properties.js"></script>

or use the below as reference and find the exact path:

   /   = Root directory
   .   = This location
   ..  = Up a directory
   ./  = Current directory
   ../ = Parent of current directory
   ../../ = Two directories backwards

Or directly get the context path to fetch the .js

<script type="text/javascript" src="<%=request.getContextPath()%>/resources/js/properties.js" >
</script>
0

While using Spring framework in mvc you have to provide resources path as below in your dispatcher-servlet.xml.

< mvc:resources mapping="/resources/**" location="/resources/" />

And then that folder will be allowed for resources. You can call them as

< script type="text/javascript" src="../../resources/js/properties.js" >
</ script>
prem30488
  • 2,828
  • 2
  • 25
  • 57