Я создал проект Web Dynami c и сгенерировал файл. xml. Затем я скопировал свой сервлет с веб-сайта и изменил его спецификации на спецификации моего проекта. Я скопировал сеть. xml и сервлет в папку WebContent по ошибке, но в то время проект работал. Когда я понял, что эти 2 файла должны быть помещены в WEB-INF, я заменил их, и теперь проект не может найти даже мои index.html
. Это иерархия моего проекта:
Это мой веб. xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
<welcome-file-list>
<welcome-file>index.html</welcome-file>
</welcome-file-list>
<display-name>Archetype Created Web Application</display-name>
<servlet>
<servlet-name>zingyBees</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>zingyBees</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
А это мой zingyBees -servlet:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:ctx="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd ">
<ctx:component-scan base-package="com.project"></ctx:component-scan>
<!--Add support for conversion, formatting and validation -->
<mvc:annotation-driven/>
<bean id="webTemplateResolver" class="org.thymeleaf.spring4.templateresolver.SpringResourceTemplateResolver">
<property name="prefix" value="/" />
<property name="templateMode" value="HTML5" />
<property name="characterEncoding" value="UTF-8" />
<property name="suffix" value=".html" />
<property name="order" value="1" />
<property name="cacheable" value="false"/>
</bean>
<!-- Thymeleaf Template Resolver -->
<bean id="templateResolver" class="org.thymeleaf.spring4.templateresolver.SpringResourceTemplateResolver">
<property name="prefix" value="/WEB-INF/html/" />
<property name="suffix" value=".html" />
<property name="templateMode" value="HTML" />
<property name="cacheable" value="false"/>
<property name="checkExistence" value="true"/>
<property name="order" value="0" />
</bean>
<!-- Thymeleaf View Resolver - implementation of Spring's ViewResolver interface -->
<bean id="viewResolver" class="org.thymeleaf.spring4.view.ThymeleafViewResolver">
<property name="templateEngine" ref="templateEngine" />
<property name="characterEncoding" value="UTF-8" />
</bean>
<!-- Thymeleaf Template Engine (Spring4-specific version) -->
<bean id="templateEngine" class="org.thymeleaf.spring4.SpringTemplateEngine">
<property name="templateResolvers">
<set>
<ref bean="templateResolver" />
<!-- <ref bean="emailTemplateResolver" /> -->
<ref bean="webTemplateResolver" />
<!-- <ref bean="UrlTemplateResolver" /> -->
</set>
</property>
</bean>
</beans>
И это мой индекс. html:
<html lang="en" data-ng-app="indexApp" data-ng-controller="indexController">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Home Page</title>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
<script src="https://use.fontawesome.com/releases/v5.0.8/js/all.js"></script>
<meta charset="ISO-8859-1">
<link rel="stylesheet" href="/ZingyBeesTest/style.css" type="text/css">
<script>
var myApp=angular.module('indexApp',[]).config(function($locationProvider) {
$locationProvider.html5Mode({
enabled : true,
requireBase : false
});
});
myApp.run(function($http) {});
myApp.controller('indexController',function($scope,$http,$location){
console.log("controller working");
$scope.contactUs=function(){
console.log("Inside angular");
var res=$http.get("/ZingyBeesTest/display/contactUs")
.success(function(data) {
console.log(data);
})
.error(function(data) {
console.log(data);
});
}
});
</script>
</head>
<body>
<!-- NAV-BAR -->
<nav class="navbar navbar-expand-lg navbar-light bg-light sticky-top">
<a class="navbar-brand" href="/ZingyBeesTest/index.html" target="_self">
<b>Zingy Bees</b>
</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav ml-auto">
<li class="nav-item">
<a class="nav-link active" href="#" target="_self">
Home
<span class="sr-only">(current)</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="WebContent/WEB-INF/html/about-us.html" target="_self">About ZB</a>
</li>
<li class="nav-item">
<a class="nav-link" href="./WEB-INF/html/contact-us.html" target="_self">Contact Us</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/WEB-INF/html/enroll-form.html" target="_self">Enroll</a>
</li>
</ul>
</div>
</nav>
<!-- Connect -->
<script language="javascript" type="text/javascript" src="./connect.txt"></script>
<!-- Footer -->
<script language="javascript" type="text/javascript" src="./footer.txt"></script>
</body>
</html>
Моя папка html в WEB-INF содержит все файлы, которые я хочу использовать в моем Navbar.