在 xhtml 页面中,jsf 属性未呈现

in xhtml page jsf attribute are not rendering

如何在 springboot 中渲染 xhtml 页面...,我应该把 xhtml 文件放在哪里

这是我的项目结构..要获取 xhtml 文件,我应该点击什么 url。 如何调用xhtml页面 这是我的 xhtml 页面

<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en" xmlns="http://www.w3.org/1999/xhtml"
    xmlns:f="http://xmlns.jcp.org/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
    xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
    xmlns:p="http://primefaces.org/ui">
<body>
    <form>
        <p:panel header="Login Page">
            <h:outputText value="id" />
            <h:inputText id="id" value="#{a.id}" required="true"></h:inputText>
            <h:message for="id" style="color:blue"></h:message>
            <br></br>
            <br></br>

            <h:outputText value="name" />
            <h:inputText id="name" value="#{a.name}" required="true"></h:inputText>
            <h:message for="name" style="color:blue"></h:message>
            <p:commandButton
                action="#{a.validate()}"
                value="login"></p:commandButton>
        </p:panel>
        <br></br>
        <br></br>
    </form>
</body>
</html>

甚至http:localhost:8080/hellourl不渲染并给出索引页

package login.example;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@Controller
@ComponentScan
public class UserController {

    @RequestMapping("/hello")
    @ResponseBody
    public String sayhii() {
        return "index";
    }

    @Autowired
    UserService userService;
    
    @GetMapping("login-register/index")
    public String index() {
        return "index";
    }
    
    
    @GetMapping("/users")
    public List<User> getAllUsers() {
        return userService.getAllUsers();
    }

    @GetMapping("/user/{id}")
    private User getUser(@PathVariable("id") long id) {
        return userService.getUserById(id);
    }

    @DeleteMapping("/user/{id}")
    public void deleteUser(@PathVariable("id") long id) {
        userService.delete(id);
    }

    @PostMapping("/users")
    public long saveUser(@RequestBody User user) {
        userService.saveOrUpdate(user);
        return user.getId();
    }

    @PutMapping("/users")
    public User Update(@RequestBody User users) {
        userService.saveOrUpdate(users);
        return users;
    }
}

这是用户控制器 class, 如何使用这个

我已经在springboot main中添加了这个class

@Bean
    public ServletRegistrationBean servletRegistrationBean() {
        FacesServlet servlet = new FacesServlet();
        return new ServletRegistrationBean(servlet, "*.xhtml");
    }

在 web.xml

中添加了这个
<servlet>
        <servlet-name>facesServlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
         <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>facesServlet</servlet-name>
        <url-pattern>*.xhtml</url-pattern>
    </servlet-mapping>
    <listener>
  <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
</listener>
     <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    <listener>
        <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
    </listener>

    <welcome-file-list>
        <welcome-file>index.xhtml</welcome-file>
                <welcome-file>faces/index.xhtml</welcome-file>
        
    </welcome-file-list>

这在我的 index.xhtml 文件中

<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:f="http://xmlns.jcp.org/jsf/core"
      xmlns:p="http://primefaces.org/ui">

现在,它正在工作

并使用此 url http://localhost:8080/index.xhtml