JSF控制器不支持spring中的post方法
我正在用Spring集成JSF和Primefaces,我想用JSF和ManagedBean作为控制器来处理导航,但由于某些原因,我无法从JSF视图向ManagedBean控制器发送请求,我收到错误:“不允许使用方法”POST“我想这是因为在Spring上下文中,我需要指定@PostMapping,但我的控制器是ManagedBean,我如何解决这个问题。先谢谢你 查看代码:JSF控制器不支持spring中的post方法,spring,jsf,primefaces,Spring,Jsf,Primefaces,我正在用Spring集成JSF和Primefaces,我想用JSF和ManagedBean作为控制器来处理导航,但由于某些原因,我无法从JSF视图向ManagedBean控制器发送请求,我收到错误:“不允许使用方法”POST“我想这是因为在Spring上下文中,我需要指定@PostMapping,但我的控制器是ManagedBean,我如何解决这个问题。先谢谢你 查看代码: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional/
<!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://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui">
<h:head>
<title>Bholamundo-jsf-cdi</title>
</h:head>
<h:body>
<f:view locale="#{languageController.locale}" />
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets" template="./WEB-INF/plantillas/plantilla.xhtml">
<ui:define name="content">
<h:form>
<table>
<tr>
<td><p:outputLabel for="username" value="#{msgs['username']}:" /></td>
<td><p:inputText id="username" required="true" value="#{userLoginView.username}" /></td>
<td><p:message for="username" class="errorMessage" /></td>
</tr>
<tr>
<td><p:outputLabel for="password" value="#{msgs['password']}:" /></td>
<td><p:password id="password" required="true" value="#{userLoginView.password}" /></td>
<td><p:message for="password" class="errorMessage" /></td>
</tr>
<tr>
<td></td>
<td><h:commandButton id="logIn" action="#{userLoginView.login}" value="#{msgs['logIn']}"/></td>
</tr>
</table>
</h:form>
</ui:define>
</ui:composition>
</h:body>
</html>
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
version="3.1">
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<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-list>
</web-app>
Facesservlet
javax.faces.webapp.FacesServlet
1.
Facesservlet
*.xhtml
org.springframework.web.context.ContextLoaderListener
org.springframework.web.context.request.RequestContextListener
index.xhtml
faces-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<faces-config 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-facesconfig_2_2.xsd"
version="2.2">
<application>
<el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver>
<!--No se necesita agregar la extension del archivo, para configurar los
mensajes -->
<resource-bundle>
<base-name>mensajes</base-name>
<var>msgs</var>
</resource-bundle>
<!--cambio de textos de validadores -->
<message-bundle>errorMessages</message-bundle>
</application>
</faces-config>
org.springframework.web.jsf.el.SpringBeanFacesELResolver
月经
msgs
错误消息
您得到的错误与JSF或PrimeFaces没有任何关系。调试。。。检查抛出错误的位置。可能是您的Spring或其他版本的servlet,但不是托管bean。您的标题是非凡的Bholamundo jsf cdi
;-)最好使用cdi而不是jsf管理的beansI我知道我的问题与jsf无关,jsf只是一个Spring配置,我敢肯定,问题是我不知道如何修复。我的名字是find:POnly,那就做一件事吧……我在你的问题中没有看到任何Spring代码。。它与春天有什么关系?
<?xml version="1.0" encoding="UTF-8"?>
<faces-config 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-facesconfig_2_2.xsd"
version="2.2">
<application>
<el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver>
<!--No se necesita agregar la extension del archivo, para configurar los
mensajes -->
<resource-bundle>
<base-name>mensajes</base-name>
<var>msgs</var>
</resource-bundle>
<!--cambio de textos de validadores -->
<message-bundle>errorMessages</message-bundle>
</application>
</faces-config>