ho cedrcato in rete ma non riesco a risolvere l'errore.
Io vorrei fare una pagina di login utente, e in base all'utente che si loga la pagina permette alcune cosa o tutto.
sono fermo ancora alla pag di login, la indirizzo giusta ma mi crea errore sul tag alla riga 9: <f:view>
index.jsp
codice:
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <% response.sendRedirect("faces/calculator.jsp"); %>
wen.xml
codice:
<?xml version="1.0" encoding="UTF-8"?> <web-app id="WebApp_ID" version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <display-name>SSWA</display-name> <context-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/applicationContext-business.xml /WEB-INF/applicationContext-security.xml</param-value> </context-param> <context-param> <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name> <param-value>resources.application</param-value> </context-param> <filter> <filter-name>springSecurityFilterChain</filter-name> <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class> </filter> <filter-mapping> <filter-name>springSecurityFilterChain</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <listener> <listener-class>com.sun.faces.config.ConfigureListener</listener-class> </listener> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <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>/faces/*</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>index.html</welcome-file> <welcome-file>index.htm</welcome-file> <welcome-file>index.jsp</welcome-file> <welcome-file>default.html</welcome-file> <welcome-file>default.htm</welcome-file> <welcome-file>default.jsp</welcome-file> </welcome-file-list> </web-app>
faces-confing.xlm
codice:
<?xml version="1.0" encoding="UTF-8"?> <faces-config xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/we...config_1_2.xsd" version="1.2"> <application> <el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver> </application> <managed-bean> <managed-bean-name>calculatorController</managed-bean-name> <managed-bean-class>org.swview.springsecuritytestapp.jsf.CalculatorController</managed-bean-class> <managed-bean-scope>request</managed-bean-scope> <managed-property> <property-name>calculator</property-name> <value>#{calculatorBean}</value> </managed-property> </managed-bean> <managed-bean> <managed-bean-name>login</managed-bean-name> <managed-bean-class>it.bean.Login</managed-bean-class> <managed-bean-scope>request</managed-bean-scope> <managed-property> <property-name>password</property-name> <property-class>java.lang.String</property-class> <value/> </managed-property> <managed-property> <property-name>user</property-name> <property-class>java.lang.String</property-class> <value/> </managed-property> </managed-bean> <navigation-rule> <display-name>login</display-name> <from-view-id>/login.jsp</from-view-id> <navigation-case> <from-outcome>submit</from-outcome> <to-view-id>/calculator.jsp</to-view-id> </navigation-case> </navigation-rule> </faces-config>
applicationContext-secutity.xlm
codice:
<?xml version="1.0" encoding="UTF-8"?> <beans:beans xmlns="http://www.springframework.org/schema/security" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schem...-beans-3.0.xsd http://www.springframework.org/schema/security http://www.springframework.org/schem...curity-3.0.xsd"> <global-method-security> <protect-pointcut access="ROLE_SPECIAL_USER" expression="execution(* org.swview.springsecuritytestapp.logic.Calculator.add(..))"/> <protect-pointcut access="ROLE_GENERAL_USER" expression="execution(* org.swview.springsecuritytestapp.logic.Calculator.subtract(..))"/> </global-method-security> <http auto-config='true'> <intercept-url pattern="/login.jsp*" access="IS_AUTHENTICATED_ANONYMOUSLY"/> <intercept-url pattern="/**" access="ROLE_USER" /> <form-login login-page='/login.jsp'/> </http> <authentication-manager> <authentication-provider> <password-encoder hash="md5"/> <user-service> <user name="kamal" password="65dc70650690999922d7dcd99dbd4033" authorities="ROLE_SPECIAL_USER" /> <user name="test" password="2a2d595e6ed9a0b24f027f2b63b134d6" authorities="ROLE_GENERAL_USER" /> </user-service> </authentication-provider> </authentication-manager> </beans:beans>
login.jsp
codice:
<%@page contentType="text/html"%> <%@page pageEncoding="UTF-8"%> <%@taglib prefix="f" uri="http://java.sun.com/jsf/core"%> <%@taglib prefix="h" uri="http://java.sun.com/jsf/html"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <f:view> <h:form>
Inserisci la UserName: <h:inputText value="#{Login.user}" id="name" required="true" /></p>
Inserisci la password: <h:inputText value="#{Login.password}" id="pwd" required="true" /></p> <h:commandButton value="Submit" action="submit" /> </h:form> </f:view>
errore
codice:
19:20:51,149 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/SSWA].[jsp]] Servlet.service() for servlet jsp threw exception: java.lang.RuntimeException: Cannot find FacesContext at javax.faces.webapp.UIComponentClassicTagBase.getFacesContext(UIComponentClassicTagBase.java:1852) [:2.0.3-] at javax.faces.webapp.UIComponentClassicTagBase.setJspId(UIComponentClassicTagBase.java:1669) [:2.0.3-] at org.apache.jsp.login_jsp._jspx_meth_f_005fview_005f0(login_jsp.java:96) at org.apache.jsp.login_jsp._jspService(login_jsp.java:74) ...............