0

PLEASE ANY HELP

Work With Spring 4.3.8.RELEASE

JPS page, MyPage.jps:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>

<html>
<head>
    <title>MyPage</title>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
    <link rel="stylesheet" href="<c:url value="/WEB-INF/static/css/itemstyle.css"/>">



    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.4/angular.js"></script>

    <spring:url value="/static/js/app.js" var="a"/>
    <script src="${a}" type="text/javascript"  ></script>
    <script src="<spring:url value="/static/js/service/item_service.js" />"  type="text/javascript"  ></script>
    <script src="<spring:url value='/static/js/controller/item_controller.js' />"  type="text/javascript"  ></script>


</head>

<body ng-app="myApp">

<div class="generic-container" ng-controller="ItemController as ctrl">
    <div class="panel panel-default">
        <div class="panel-heading"><span class="lead">User Registration Form </span></div>
        <div class="formcontainer">
            <!-- form submit -->
        </div>
    </div>
    <div class="panel panel-default">
        <!-- Default panel contents -->
        <div class="panel-heading"><span class="lead">List of Users </span></div>
        <div class="tablecontainer">
            <table class="table table-hover">
                <thead>
                <tr>
                    <th>ID.</th>
                    <th>Name</th>
                    <th>Address</th>
                    <th>Email</th>
                    <th width="20%"></th>
                </tr>
                </thead>
                <tbody>
                <tr ng-repeat="i in ctrl.items">
                    <td><span ng-bind="i.id"></span></td>
                    <td><span ng-bind="i.name"></span></td>
                    <td><span ng-bind="i.price"></span></td>
                    <!--td>
                        <button type="button" ng-click="ctrl.edit(i.id)" class="btn btn-success custom-width">Edit</button>  <button type="button" ng-click="ctrl.remove(i.id)" class="btn btn-danger custom-width">Remove</button>
                    </td-->
                </tr>
                </tbody>
            </table>
        </div>
    </div>
</div>





</body>
</html>

Servlet item-serlvet :

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"
       xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">

    <context:component-scan base-package="mayan.example" />

    <context:annotation-config/>

    <mvc:resources mapping="/static/**" location="/WEB-INF/static/" cache-period="31556926"/>

    <mvc:annotation-driven/>
    <mvc:default-servlet-handler/>


    <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix" value="/WEB-INF/views/" />
        <property name="suffix" value=".jsp" />
    </bean>



</beans>

Web :

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
         version="3.1">

    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

    <servlet-mapping>
        <servlet-name>item</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>

    <servlet>
        <servlet-name>item</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>WEB-INF/app-context.xml</param-value>
    </context-param>

    <welcome-file-list>
        <welcome-file></welcome-file>
    </welcome-file-list>


</web-app>

i hope i don'd make duplicate cecause i already read :

JavaScript with Spring MVC doesn't work

Where do CSS and JavaScript files go in a Maven web app project?

https://www.mkyong.com/spring-mvc/spring-mvc-how-to-include-js-or-css-files-in-a-jsp-page/

Including css and js file in spring mvc 3

how to load js file in spring mvc

How to include js and CSS in JSP with spring MVC

and more

PROBLEM

java Scripts files not loaded. intends i see the jps page in the resources in the web like so

enter image description here

when the file app.js is this :

'use strict';

var App = angular.module('myApp',[]);

really no have idea what do to, already tried so many and 4 hours on this problem. thk for any help !

My Project :

enter image description here

6
  • 1
    Are your static files in your WEB-INF folder ? Commented Jun 29, 2017 at 12:41
  • Yes as you can see in the image in my bottom question. Commented Jun 29, 2017 at 12:45
  • for example. app.js in web->WEB-INF->static->js->app.js Commented Jun 29, 2017 at 12:46
  • and i tried in web->static->js->app.js as well... Commented Jun 29, 2017 at 12:46
  • I sow it. But I was wondering because static files are nit supposed to be stored in WEB-INF. Also,I never put html tags inside .js files. Commented Jun 29, 2017 at 12:48

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.