I develop this contact form:
<!DOCTYPE html>
<ui:composition
xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
<h:form>
<h:panelGrid columns="3">
<h:outputLabel for="name" value="Nome (Obrigatório)" />
<h:inputText id="name" value="#{contact.client.name}" />
<h:message for="name" />
<h:outputLabel for="email" value="E-Mail (Obrigatório)" />
<h:inputText id="email" value="#{contact.client.email}" />
<h:message for="email" />
<h:outputLabel for="website" value="Website (Opcional)" />
<h:inputText id="website" value="#{contact.client.website}" />
<h:message for="website" />
</h:panelGrid>
<h:outputLabel for="text" value="Mensagem (Obrigatório):" /> <br/>
<h:inputTextarea id="text" value="#{contact.client.text}" rows="20" cols="80" /><br/>
<h:message for="text" />
<br/>
<h:commandButton value="Enviar" action="#{contact.sendMessage}" >
<f:ajax execute="#form" render="#form" />
</h:commandButton>
<h:outputText value="#{contact.messageStatus}" id="out" />
<a4j:status>
<f:facet name="start">
<h:graphicImage name="loader.gif" library="image" />
<h:outputText value="Enviando ..." />
</f:facet>
</a4j:status>
</h:form>
</ui:composition>
I import this composition in my contact page, but I don't know why, it puts this scripts in the end of the <h:head>..</h:head> section:
<script type="text/javascript" src="/Project/javax.faces.resource/jsf.js.xhtml?ln=javax.faces"></script>
<script type="text/javascript" src="/Project/javax.faces.resource/jquery.js.xhtml"></script>
<script type="text/javascript" src="/Project/javax.faces.resource/richfaces.js.xhtml"></script>
<script type="text/javascript" src="/Project/javax.faces.resource/richfaces-queue.js.xhtml"></script>
<script type="text/javascript" src="/Project/javax.faces.resource/richfaces-base-component.js.xhtml"></script>
<script type="text/javascript" src="/Project/javax.faces.resource/status.js.xhtml?ln=org.richfaces"></script>
I already try to disable richfaces style with this parameters in my web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app //.. configs>
<display-name>Project</display-name>
<context-param>
<param-name>javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>org.richfaces.skin</param-name>
<param-value>plain</param-value>
</context-param>
<context-param>
<param-name>org.richfaces.enableControlSkinning</param-name>
<param-value>false</param-value>
</context-param>
<welcome-file-list>
<welcome-file>index.xhtml</welcome-file>
</welcome-file-list>
<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>
</web-app>
With these style, scripts that are added in the end of my section my footer just disappeared, how could I fix that ?
Any idea ?
I added these lines to the web.xml. This worked for me.
<context-param>
<param-name>org.richfaces.skin</param-name>
<param-value>plain</param-value>
</context-param>
<context-param>
<param-name>org.richfaces.LoadStyleStrategy</param-name>
<param-value>None</param-value>
</context-param>
<context-param>
<param-name>org.richfaces.enableControlSkinning</param-name>
<param-value>false</param-value>
</context-param>
Related
This question already has answers here:
Spring security 4 custom login j_spring_security_check return http 302
(4 answers)
Closed 4 years ago.
I am new to spring security, I am trying to implement security for my spring mvc application. The problem is I am routing to my custom login page and entering valid credentials but it again routing to the same login page. The below is the configurations.
web.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" version="3.0">
<display-name>SpringTiles</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>spring</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring-security.xml
</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>
</web-app>
spring-security.xml
<b:beans xmlns="http://www.springframework.org/schema/security"
xmlns:b="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-4.2.xsd ">
<b:bean id="springSecurityFilterChain" class="org.springframework.web.filter.DelegatingFilterProxy" />
<http pattern="/login" security="none" />
<http use-expressions="true">
<intercept-url pattern="/**" access="isAuthenticated()" />
<form-login login-page="/login" default-target-url="/welcome" authentication-failure-url="/login" />
<logout logout-url="/logout" logout-success-url="/welcome" />
<csrf disabled="true"/>
</http>
<authentication-manager>
<authentication-provider>
<user-service>
<user name="admin" password="admin" authorities="Admin,User" />
</user-service>
</authentication-provider>
</authentication-manager>
</b:beans>
If I specify only <form-login/> and removed <http pattern="/login" security="none" /> application is working fine. But I want show my custom login page.
Login.jsp
<form action="j_spring_security_check" method="POST" >
<div class="form-group">
<label for="exampleInputEmail1">User Name</label>
<input type="text" class="form-control" name="j_username" placeholder="Enter User Name" required="required">
</div>
<div class="form-group">
<label for="exampleInputPassword1">Password</label>
<input type="password" class="form-control" name="j_password" placeholder="Password" required="required">
</div>
<button type="submit" style="width: 100%;background: #347AB6; font-size:1.1em;" class="btn btn-large btn btn-lg btn-block bg-primary" ><b>Login</b></button>
</form>
<font color="red">
<span>${sessionScope["SPRING_SECURITY_LAST_EXCEPTION"].message}</span>
</font>
Spring Framework version - 4.3.7.RELEASE And
Spring Security version - 4.2.3.RELEASE
Please help where I am doing wrong.
Thank you.
I got to fix my issue with the help of the above link http://www.baeldung.com/spring-security-login
Here is my updated code
<b:beans xmlns="http://www.springframework.org/schema/security"
xmlns:b="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-4.2.xsd ">
<b:bean id="springSecurityFilterChain" class="org.springframework.web.filter.DelegatingFilterProxy" />
<http use-expressions="true">
<intercept-url pattern="/login*" access="isAnonymous()" />
<intercept-url pattern="/**" access="isAuthenticated()"/>
<form-login login-page="/login" default-target-url="/homepage" authentication-failure-url="/login"
always-use-default-target="true" />
<logout logout-url="/logout" logout-success-url="/login" />
<csrf disabled="true"/>
</http>
<authentication-manager>
<authentication-provider>
<user-service>
<user name="admin" password="admin" authorities="Admin,User" />
</user-service>
</authentication-provider>
</authentication-manager>
</b:beans>
Since j_spring_security_check is deprecated I have used `login' in my jsp action.
I've tried to fix this issue by myselft over a week but still don't know where i was wrong. I also read all the posts that have similar issue but can't find the solution for my case.
Web 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"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
<!-- Servlet config begin -->
<servlet>
<servlet-name>vietjob</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>vietjob</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<!-- end-->
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<filter>
<filter-name>encodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>encodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- Begin load Spring Filter Chain config from servlet vietjob -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/vietjob_security.xml
</param-value>
</context-param>
<!-- end load -->
<!-- Begin Spring security config-->
<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>
<!-- End Spring security config -->
</web-app>
Security xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:util="http://www.springframework.org/schema/util"
xmlns:sec="http://www.springframework.org/schema/security"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/security
http://www.springframework.org/schema/security/spring-security.xsd">
<import resource="vietjob-data.xml" />
<!-- Begin Spring security config -->
<sec:http auto-config="true" use-expressions="true">
<sec:intercept-url pattern="/secure/admin/**"
access="hasRole('ROLE_YLLAPITAJA')" />
<sec:intercept-url pattern="/secure/employee/*" access="hasRole('ROLE_EHDOKAS')" />
<sec:intercept-url pattern="/secure/hakemus/*" access="hasRole('ROLE_EHDOKAS')" />
<sec:intercept-url pattern="/secure/partner/*"
access="hasRole('ROLE_PARTNERI')" />
<sec:intercept-url pattern="/secure" access="isAuthenticated()" />
<sec:intercept-url pattern="/lomake.do" access="isAuthenticated()" />
<sec:intercept-url pattern="/*" access="permitAll" />
<sec:form-login login-page="/login.do"
default-target-url="/secure"
authentication-failure-url="/loginfail.do" />
<sec:logout logout-success-url="/logout.do" />
<sec:csrf disabled="true"/>
</sec:http>
<bean id="encoder"
class="org.springframework.security.crypto.password.StandardPasswordEncoder" />
<sec:authentication-manager>
<sec:authentication-provider>
<sec:password-encoder ref="encoder" />
<sec:jdbc-user-service data-source-ref="dataSource"
users-by-username-query="select kayttaja_tunnus, kayttaja_salasana_encrypted, kayttaja_enabled from kayttaja where kayttaja_tunnus=? and enabled = 1"
authorities-by-username-query="select k.kayttaja_tunnus, r.rooli from kayttaja k JOIN kayttaja_rooli kr ON (r.fk_kayttaja_id = kr_kayttaja_id) JOIN rooli r ON (r.rooli_id = kr.fk_rooli_id) WHERE k.kayttaja_tunnus = ?" />
</sec:authentication-provider>
</sec:authentication-manager>
<sec:global-method-security
pre-post-annotations="enabled" />
<!-- End Spring security config -->
</beans>
login form
<h3><spring:message code="login.kirjaudu.kayttaja" /></h3>
<hr>
<c:if test="${not empty loginerror}">
<p>Sisäänkirjautuminen epäonnistui. Käyttäjätunnus tai salasana on syötetty väärin.</p>
</c:if>
<c:if test="${not empty loggedout}">
<p>Uloskirjautuminen onnistui</p>
</c:if>
<spring:url value='j_spring_security_check' var="springcheck"></spring:url>
<form action='${springcheck }' class="form-horizontal" role="form" method="post">
<div class="form-group">
<label class="control-label col-sm-2"><spring:message code="login.tunnus.kayttaja"></spring:message>:</label>
<div class="col-sm-4">
<input type="text" class="form-control" name="j_username" placeholder="Enter username" />
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" ><spring:message code="login.salasana.kayttaja"></spring:message>:</label>
<div class="col-sm-4">
<input type="password" class="form-control" name="j_password" placeholder="Enter password" />
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-4">
<div class="checkbox">
<label><input type="checkbox"> <spring:message code="login.remember.kayttaja"></spring:message></label>
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-4">
<button type="submit" class="btn btn-default"><spring:message code="login.kirjaudu.kayttaja"/></button>
</div>
</div>
</form>
Anyone can help me? i've ready to give up :(.
You have two choices:
1. Change to version 3.2
or
2. In spring security config, you add login-processing-url="/j_spring_security_check" in <sec:form-login> tag.
The default values are changed in Spring security 4
https://docs.spring.io/spring-security/site/docs/4.2.0.RELEASE/reference/htmlsingle/#nsa-form-login-attributes
https://docs.spring.io/spring-security/site/docs/3.2.0.RELEASE/reference/htmlsingle/#nsa-form-login-attributes
please i need help for my project,the authentication does not proceed when i use the custom login page it always show user or password invalid.
pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.football</groupId>
<artifactId>reservation</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>reservation Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>4.2.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>4.2.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>4.2.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>4.2.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>4.0.3.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
<version>4.0.3.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>4.0.3.RELEASE</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.3</version>
</dependency>
<dependency>
<groupId>jstl</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
</dependencies>
<build>
<finalName>reservation</finalName>
</build>
</project>
Web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
id="WebApp_ID" version="3.1">
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:/spring/mvc-config.xml,
classpath:/spring/security-config.xml,
</param-value>
</context-param>
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextAttribute</param-name>
<param-value>org.springframework.web.context.WebApplicationContext.ROOT</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/login</url-pattern>
<url-pattern>/</url-pattern>
</servlet-mapping>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- Spring Security -->
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
<init-param>
<param-name>contextAttribute</param-name>
<param-value>org.springframework.web.context.WebApplicationContext.ROOT</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
Login.jsp
<!doctype html>
<%# page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<%#taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%# taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<spring:url value="/resources/css/bootstrap.min.css" var="bootstrapcss" />
<link href="${bootstrapcss}" rel="stylesheet" />
<spring:url value="/resources/css/formValidation.min.css"
var="formValidation" />
<link href="${formValidation}" rel="stylesheet" />
<spring:url value="/resources/css/navbar.css" var="navbar" />
<link href="${navbar}" rel="stylesheet" />
<spring:url value="/resources/css/main.css" var="main" />
<link href="${main}" rel="stylesheet" />
<title>Login</title>
</head>
<body>
<jsp:include page="Header.jsp" />
<section class="container-fluid">
<div class="row">
<div class="jumbotron col-centered col-md-4 col-sm-6 col-xs-9">
<c:if test="${param.login_error != null}">
Invalid username / password
</c:if>
<c:url var="loginUrl" value="/login" />
<form class="form-horizontal" role="form" action="${loginUrl}"
method="post">
<div class="form-group">
<label for="username">UserName</label> <input type="text"
class="form-control" id="username" name="username"
placeholder="Enter username">
</div>
<div class="form-group">
<label for="password">Password</label> <input type="password"
class="form-control" id="password" name="password"
placeholder="Password">
</div>
<div class="checkbox">
<label> <input type="checkbox"> Remember Me
</label>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-primary">Login</button>
<button type="button" class="btn btn-default">Cancel</button>
<span class="glyphicon glyphicon-lock"></span> Inscrivez-vous
</div>
<input type="hidden" name="${_csrf.parameterName}"
value="${_csrf.token}" />
</form>
</div>
</div>
</section>
<jsp:include page="InfoSite.jsp" />
<jsp:include page="MostPopularTickets.jsp" />
<jsp:include page="Footer.jsp" />
<jsp:include page="CopyRight.jsp" />
<spring:url value="/resources/js/jquery-1.11.3.min.js" var="jquery_url" />
<script src="${jquery_url }" type="text/javascript"></script>
<spring:url value="/resources/js/bootstrap.min.js" var="bootstrap_url" />
<script src="${bootstrap_url }" type="text/javascript"></script>
<spring:url value="/resources/js/formValidation.min.js"
var="formValidation_url" />
<script src="${formValidation_url}" type="text/javascript"></script>
<spring:url value="/resources/js/bootstrap.min-validation.js"
var="bootstrap.min-validation_url" />
<script src="${bootstrap.min-validation_url}" type="text/javascript"></script>
<spring:url value="/resources/js/script.js" var="script_url" />
<script src="${script_url}" type="text/javascript"></script>
</body>
</html>
security-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:security="http://www.springframework.org/schema/security"
xsi:schemaLocation="http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-4.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<security:http use-expressions="true" disable-url-rewriting="true"
auto-config="true">
<security:intercept-url pattern="/resources/**"
access="permitAll()" />
<security:intercept-url pattern="/Ligue1Pro"
access="hasRole('ROLE_ADMIN')" />
<security:intercept-url pattern="/registration"
access="permitAll()" />
<security:intercept-url pattern="/login"
access="permitAll()" />
<security:intercept-url pattern="/" access="permitAll()" />
<security:form-login default-target-url="/" login-page="/login"
authentication-failure-url="/login?login_error"
always-use-default-target="true" password-parameter="username"
username-parameter="password" />
<security:csrf />
</security:http>
<security:authentication-manager>
<security:authentication-provider>
<security:user-service>
<security:user name="user" authorities="ROLE_ADMIN"
password="user" />
</security:user-service>
</security:authentication-provider>
</security:authentication-manager>
</beans>
mvc-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd">
<mvc:default-servlet-handler />
<mvc:annotation-driven />
<context:component-scan base-package="com.footballreservation.controller" />
<mvc:resources location="/resources/" mapping="/resources/**" />
<mvc:view-controller path="/" view-name="home" />
<bean
class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping">
</bean>
<bean
class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter">
</bean>
<bean id="viewResolver"
class="org.springframework.web.servlet.view.UrlBasedViewResolver">
<property name="viewClass"
value="org.springframework.web.servlet.view.JstlView" />
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
</bean>
</beans>
MainController.java
package com.footballreservation.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
#Controller("MainController")
public class MainController {
#RequestMapping("/,home")
public String showHome() {
return "home";
}
#RequestMapping(value = "/Ligue1Pro", method = RequestMethod.GET)
public String showLigue1ProPage() {
return "Ligue1Pro";
}
#RequestMapping(value = "/login", method = RequestMethod.GET)
public String showLoginPage() {
return "Login";
}
#RequestMapping(value = "/registration", method = RequestMethod.GET)
public String showregistrationPage() {
return "Register";
}
}
It looks like the problem lies in your spring security configuration file (security-config.xml), as per your code you have given
password-parameter="username"
username-parameter="password"
try changing it to
password-parameter="password"
username-parameter="username"
Problem
I am developing an application using Spring 4.1.1 and Tiles 3.0.5. I could able to create Layout. When I add the Image tag directly in the layout.jsp, I could able to see the Images/CSS etc, but when I add same Image tag in the different JSP which is added as "attribute" to the Layout, then none of the resources is working.
"I can see error in console as
org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/abc/%3Cc:url%20value=%22/resources/images/slides/trial.jpg%22%20/%3E] in DispatcherServlet with name "abc".
Web.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_2_5.xsd" version="2.5">
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:spring/applicationContext-resource.xml
/WEB-INF/spring/applicationContext-base.xml
/WEB-INF/spring/applicationContext-dao.xml
</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>abc</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/applicationContext.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>abc</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
Application Context
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<beans:bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping" id="handlerMapping">
<beans:property name="alwaysUseFullPath" value="true"/>
</beans:bean>
<!-- DispatcherServlet Context: defines this servlet's request-processing infrastructure -->
<!-- Enables the Spring MVC #Controller programming model -->
<annotation-driven />
<!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/resources directory -->
<resources mapping="/resources/**" location="/resources/" />
<resources mapping="/styles/**" location="/resources/css" />
<resources mapping="/images/**" location="/resources/images"/>
<resources mapping="/js/**" location="/resources/js"/>
<resources mapping="/fonts/**" location="/resources/fonts"/>
<!-- Resolves views selected for rendering by #Controllers to .jsp resources in the /WEB-INF/views directory -->
<beans:bean id="tilesConfigurer"
class="org.springframework.web.servlet.view.tiles3.TilesConfigurer">
<beans:property name="definitions">
<beans:list>
<beans:value>/WEB-INF/tiles-defs/templates.xml</beans:value>
</beans:list>
</beans:property>
</beans:bean>
<beans:bean id="viewResolver"
class="org.springframework.web.servlet.view.UrlBasedViewResolver">
<beans:property name="viewClass" value="org.springframework.web.servlet.view.tiles3.TilesView" />
</beans:bean>
<context:component-scan base-package="com.online.abc" />
</beans:beans>
Tiles Definition
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE tiles-definitions PUBLIC
"-//Apache Software Foundation//DTD Tiles Configuration 2.0//EN"
"http://tiles.apache.org/dtds/tiles-config_2_0.dtd">
<tiles-definitions>
<definition name="baseLayout" template="/WEB-INF/views/layout/layout.jsp">
<put-attribute name="title" value="abc" />
<put-attribute name="header" value="/WEB-INF/views/layout/header.jsp" />
<put-attribute name="navigation" value="/WEB-INF/views/layout/navigation.jsp" />
<put-attribute name="slider" value="/WEB-INF/views/layout/slider.jsp"/>
<put-attribute name="body" value="" />
<put-attribute name="footer" value="/WEB-INF/views/layout/footer.jsp" />
</definition>
<definition extends="baseLayout" name="login">
<put-attribute name="title" value="SivaLabs : Login" />
<put-attribute name="navigation" value="" />
<put-attribute name="body" value="/WEB-INF/views/login.jsp" />
</definition>
<definition extends="baseLayout" name="home">
<put-attribute name="title" value="SivaLabs : Welcome" />
<put-attribute name="body" value="/WEB-INF/views/home.jsp" />
</definition>
</tiles-definitions>
Layout.jsp
<!DOCTYPE html>
<%# taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%>
<%# taglib uri="http://java.sun.com/jstl/core" prefix="c"%>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><tiles:insertAttribute name="title" ignore="true" /></title>
<link rel="stylesheet" type="text/css" href='<c:url value="/resources/css/styles.css" />' />
<script src='<c:url value="/resources/js/jquery/jquery-2.1.3.min.js" />'> </script>
<script src='<c:url value="/resources/js/unslider/unslider.js" />'> </script>
</head>
<body class="body">
<div class="headerContent">
<header class="mainHeader">
<tiles:insertAttribute name="header" />
</header>
</div>
<tiles:insertAttribute name="slider" />
<%-- <content>
<tiles:insertAttribute name="body" />
</content> --%>
<%-- <footer>
<tiles:insertAttribute name="footer" />
</footer> --%>
</body>
</html>
Slider.jsp
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<script type="text/javascript">
$(function() {
$('.banner').unslider();
});
</script>
<body>
<div class="banner">
<ul>
<li><img src='<c:url value="/resources/images/slides/visa.jpg" />'></li>
</ul>
</div>
</body>
</html>
If I use same code of slider.jsp in layout.jsp, it is working.
I found solution but have no clue what is the problem. Found the solution from this link
JavaScript with Spring MVC doesn't work
I'm trying create a composite component to use across my projects, so, I've created a project called "componentes-ui-web" and putted 2 xhtml files that are my components.
The structure of the project is like this:
src
> |-> main
> > |->java
> > |->META-INF
> > |->faces-config.xml
> > |->resources
> > |->componentes
> > |->popupSimples.xhtml
> > |->popupSubmit.xhtml
This is the code of popupSubmit.xhtml:
<!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:ui="http://java.sun.com/jsf/facelets"
xmlns:icecore="http://www.icefaces.org/icefaces/core"
xmlns:ice="http://www.icesoft.com/icefaces/component"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:composite="http://java.sun.com/jsf/composite"
xmlns:ace="http://www.icefaces.org/icefaces/components">
<composite:interface>
<composite:attribute name="modal" default="false" />
<composite:attribute name="visivel" default="false" />
<composite:attribute name="style" default="" />
<composite:attribute name="titulo" default="Sem título definido" />
<composite:attribute name="exibidoQuandoTipoUsuario" default="" />
<composite:attribute name="metodoFechar"
method-signature="java.lang.Void fechar()" required="true" />
<composite:attribute name="metodoSubmeter"
method-signature="java.lang.Void submeter()" required="true" />
<composite:facet name="conteudo" />
</composite:interface>
<composite:implementation>
<h:form>
<ice:panelPopup modal="#{cc.attrs.modal}"
renderedOnUserRole="#{cc.attrs.exibidoQuandoTipoUsuario}"
draggable="#{cc.attrs.modal}" rendered="#{cc.attrs.visivel}"
clientOnly="true" autoCentre="true" style="#{cc.attrs.style}">
<f:facet name="header">
<ui:insert name="barraDeTitulos">
<ice:panelLayout layout="flow" style="width:100%">
<h:outputText value="#{cc.attrs.titulo}" style="float:left" />
<h:commandLink value="[X]" style="float:right"
action="#{cc.attrs.metodoFechar}" immediate="true" />
</ice:panelLayout>
</ui:insert>
</f:facet>
<f:facet name="body">
<ice:panelLayout layout="flow" style="width:100%">
<composite:renderFacet name="conteudo" />
<ui:insert name="barraDeBotoes">
<ice:panelLayout layout="flow">
<ace:pushButton value="CANCELAR" immediate="true"
style="float:right" action="#{cc.attrs.metodoFechar}" />
<ace:pushButton value="OK" style="float:right"
action="#{cc.attrs.metodoSubmeter}" />
</ice:panelLayout>
</ui:insert>
</ice:panelLayout>
</f:facet>
</ice:panelPopup>
</h:form>
</composite:implementation>
</html>
In another Web project I try to use this component simply adding that jar to the lib (maven) and adding the tag:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:icecore="http://www.icefaces.org/icefaces/core"
xmlns:ice="http://www.icesoft.com/icefaces/component"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:hrgi="http://java.sun.com/jsf/composite/componentes"
xmlns:ace="http://www.icefaces.org/icefaces/components">
<ui:component>
<f:loadBundle basename="com.hrgi.web.configuracoes.messages"
var="configuracoesMsg" />
<hrgi:popupSubmit modal="true" visivel="true"
titulo="#{configuracoesMsg['popup.importador_nfe.titulo']}"
exibidoQuandoTipoUsuario="ROLE_ADMINISTRADOR"
metodoFechar="#{controladorPopupConfiguracaoImportadorNFe.fechar}"
metodoSubmeter="#{controladorPopupConfiguracaoImportadorNFe.submeter}">
<f:facet name="conteudo">
...
</hrgi:popupSubmit>
</ui:component>
</html>
When I run the application, the component isn't shown and I receive this message in the firefox:
Warning: This page calls for XML namespace http://java.sun.com/jsf/composite/componentes declared with prefix hrgi but no taglibrary exists for that namespace.
What I did wrong??
Update thanks for the replies and sorry for the late to answer...
I've created the ResourceResolver like BalusC told, but without success.
I've checked the output of tomcat too, but didn't find any error.
This is my web.xml file, perhaps someone can find anything that could help me.
I will search about ResourceHandler too.
<?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" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<display-name>teste-zk</display-name>
<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>
<url-pattern>/icefaces/*</url-pattern>
</servlet-mapping>
<context-param>
<param-name>javax.faces.FACELETS_RESOURCE_RESOLVER</param-name>
<param-value>com.hrgi.web.ui.FaceletsResourceResolver</param-value>
</context-param>
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>server</param-value>
</context-param>
<context-param>
<param-name>com.sun.faces.enableMissingResourceLibraryDetection</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<context-param>
<param-name>javax.faces.FACELETS_SKIP_COMMENTS</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>javax.faces.VALIDATE_EMPTY_FIELDS</param-name>
<param-value>false</param-value>
</context-param>
<servlet>
<servlet-name>Resource Servlet</servlet-name>
<servlet-class>com.icesoft.faces.webapp.CompatResourceServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Resource Servlet</servlet-name>
<url-pattern>/xmlhttp/*</url-pattern>
</servlet-mapping>
</web-app>
I've solved the problem. I've looked inside the jar file and didn't see the META-INF/resources folder with the xhtml files. So I changed the META-INF folder from src/main/java to src/main/resources. It worked
You should check if the ResourceHandler installed can locate the library and resource (popupSubmit.xhtml) inside you JAR file. Use a ResourceResolver will not help, because it is used for facelets (ui:xxx and facelet views). If there is some ResourceHandler wrapper that prevents locate the library and the resource, or some other problem on the classpath, it is expected the warning you are looking can be seen.