Я использую библиотеку bootsFaces для моего веб-проекта JSF. Когда я использую перенаправление страниц с ajax, я получаю сообщение: «JSF: malformedXML: Во время обновления: javax.faces.Resource not found». Странная вещь в том, что страницы без тега: все еще могут использоваться как обычно, но не могут. Кто-нибудь может мне помочь. Вот мой код Student.xhtml
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:b="http://bootsfaces.net/ui">
<h:head>
<title>Facelet Title</title>
</h:head>
<h:body>
<ui:composition>
<b:form>
<b:dataTable value="#{studentController.getStudent()}" var="student" select="true">
<b:dataTableColumn value="#{student.id}" label="ID"/>
<b:dataTableColumn value="#{student.name}" label="TÊN"/>
<b:dataTableColumn value="#{student.department_name}" label="Phòng ban"/>
<b:dataTableColumn value="#{student.tot_cred}" label="Tín chỉ"/>
</b:dataTable>
</b:form>
</ui:composition>
</h:body>
</html>
StudentController.java
package Controller;
import Define.SQLDefine;
import Model.Student;
import Model.Model;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.faces.bean.ApplicationScoped;
import javax.faces.bean.ManagedBean;
import javax.faces.view.ViewScoped;
@ManagedBean
@ViewScoped
public class StudentController extends Model {
public ArrayList<Student> getStudent() {
ArrayList<Student> students = new ArrayList<>();
try {
PreparedStatement stmt = connection.prepareCall(SQLDefine.getSQL(3));
ResultSet resStudent = stmt.executeQuery();
if (resStudent.next()) {
resStudent.beforeFirst();
while (resStudent.next()) {
students.add(
new Student(
resStudent.getInt(1),
resStudent.getString(2),
resStudent.getString(3),
resStudent.getInt(4)
));
}
}
} catch (SQLException ex) {
Logger.getLogger(StudentController.class.getName()).log(Level.SEVERE, null, ex);
System.out.println("29111999: " + ex.getMessage());
}
return students;
}
}
Home.xhtml
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html>
<html
xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:b="http://bootsfaces.net/ui">
<h:head>
<title>Home Controller</title>
<link type="text/css" href="./css/style.css"/>
<link rel="shortcut icon" type="image/x-icon" href="../img/favicon.ico" />
</h:head>
<h:body>
<!-- Header -->
<ui:insert name="Header">
<ui:include src="include/Header.xhtml"/>
</ui:insert>
<!-- Content -->
<b:container class="MainContent">
<ui:insert name="content">
<ui:include src="#{homeBean.page}"/>
</ui:insert>
</b:container>
<!-- UI -->
<ui:insert>
<ui:include src="include/UserModal.xhtml"/>
</ui:insert>
</h:body>
<!-- Script JS -->
<script>
$.blockUI.defaults.css.width = '20%';
$.blockUI.defaults.css.left = '40%';
$.blockUI.defaults.css.height = '5em';
$.blockUI.defaults.css.borderRadius = '10px';
$.blockUI.defaults.overlayCSS.opacity = 0.5;
$.blockUI.defaults.message = '<div style="padding-top:1em"><img src="../img/pikachu.gif" alt="Wait" style="width: 60px; heifgt: 60px"/></div>';
</script>
</html>
Header.xhtml
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:b="http://bootsfaces.net/ui"
xmlns:f="http://xmlns.jcp.org/jsf/core">
<h:head>
<title>Header</title>
</h:head>
<h:body>
<ui:composition>
<h:form>
<b:navBar brand="TelSoft" brandHref="#">
<b:navbarLinks>
<b:navLink
href="#"
value="Home"
icon-awesome="fa-home"
update="@form @(.MainContent)"
onclick="ajax:homeBean.setPage('include/Home.xhtml')"/>
<b:navLink
href="#"
value="Import course"
icon-awesome="fa-download"
update="@form @(.MainContent)"
onclick="ajax:homeBean.setPage('include/ImportCourse.xhtml')"/>
<b:dropMenu value="Quản lý" iconAwesome="fas fa-cog">
<b:navLink
href="#"
value="Sinh viên"
icon-awesome="fa-child"
update="@form @(.MainContent)"
onclick="ajax:homeBean.setPage('include/Student.xhtml')"/>
<b:navLink
href="#"
value="Giáo viên"
icon-awesome="fa-female"
update="@form @(.MainContent)"
onclick="ajax:homeBean.setPage('include/Teacher.xhtml')"/>
<b:navLink
href="#"
value="Thư viện"
icon-awesome="fa-book"
update="@form @(.MainContent)"
onclick="ajax:homeBean.setPage('include/Library.xhtml')"/>
</b:dropMenu>
</b:navbarLinks>
<b:navbarLinks pull="right" class="text-center">
<li>
<a href="#userModal" data-toggle="modal">
<b:iconAwesome name="fa-user"/>
Xin chào: #{homeBean.fullName}
</a>
</li>
</b:navbarLinks>
</b:navBar>
</h:form>
</ui:composition>
</h:body>
</html>