I have a problem with redirect in Spring MVC. I have a controller with few methods:
//PRINT ALL WORKERS
#RequestMapping("/print")
public String listWorkers(Model model)
{
model.addAttribute("workerList", workerService.getAllWorkers());
return "print";
}
//EDIT WORKER DATA
#RequestMapping("/edit")
public String redirectWorker(HttpServletRequest request)
{
String parameter = request.getParameter("workers");
String path = "redirect:/edit/" + parameter;
return path;
}
#RequestMapping("/edit/{worker}")
public String editWorker(#PathVariable("worker")
String login, Model model)
{
model.addAttribute("worker", workerService.getWorker(login));
return "edition";
}
When I'm using in my program for example method with "print" in request mapping, my URL is:
http://localhost:8080/WWP/print
But when I'm using my method with "edit/{worker}" in request mapping and after that I used method with "print" I got an URL:
http://localhost:8080/WWP/edit/print
Cause my "print" was added after "edit" which isn't necessary. How to return to previous URL:
http://localhost:8080/WWP/print
I suppose that I have to change my RequestMapping annotation. But I don't know how to do this.
EDIT:
Ok, here is my web.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<web-app 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">
<!-- The definition of the Root Spring Container shared by all Servlets and Filters -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/root-context.xml, /WEB-INF/spring/appServlet/security.xml</param-value>
</context-param>
<!-- Creates the Spring Container shared by all Servlets and Filters -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- Processes application requests -->
<servlet>
<servlet-name>appServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/appServlet/servlet-context.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>appServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<!-- Filtry -->
<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>
<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>
I used the "c:url" in the JSP and it worked.
For example:
It will be remember the previous URL (It's wrong):
My Events
It will be good:
<c:url var="myEventsUrl" value="/events/my" />
My Events
URL is always link to: _http://localhost:8080/WWP/events/my
Related
I'm injecting two beans inside my backing bean with ManagedProperty. The backing bean is view scope and the model bean is request scope that looks like this:
#ManagedBean(name = "categoryBB")
#ViewScoped
public class CategoryBackingBean implements Serializable {
private static final long serialVersionUID = -880184144170934066L;
private static final Logger LOG = Logger
.getLogger(CategoryBackingBean.class);
#ManagedProperty("#{categoryService}")
CategoryService categoryService;
#ManagedProperty("#{categoryBean}")
CategoryBean categoryBean;
//Getters/Setters...
}
However I'm receiving the following error:
javax.servlet.ServletException: Unable to create managed bean categoryBB.
The following problems were found:
The scope of the object referenced by expression #{categoryBean}, request, is shorter than the referring managed beans (categoryBB) scope of view
javax.faces.webapp.FacesServlet.service(FacesServlet.java:659)
My web.xml
<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>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/spring-security.xml
/WEB-INF/applicationContext.xml
</param-value>
</context-param>
<!-- Enable Spring-Security TagLib in JSF -->
<context-param>
<param-name>javax.faces.FACELETS_LIBRARIES</param-name>
<param-value>/WEB-INF/springsecurity.taglib.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>
<dispatcher>FORWARD</dispatcher>
<dispatcher>REQUEST</dispatcher>
<dispatcher>ERROR</dispatcher>
</filter-mapping>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
<listener-class>
org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>
Any suggestion?
I am encountering problems getting spring profiles to work with cloudfoundry. My profiles are not picked up by cloudfoundry's tomcat...
Here is my web.xml:
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="3.0" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" metadata-complete="true">
<display-name>kadjoukor</display-name>
<description>Roo generated kadjoukor application</description>
<!-- Enable escaping of form submission contents -->
<context-param>
<param-name>defaultHtmlEscape</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:META-INF/spring/applicationContext*.xml classpath:META-INF/cloud/cloudfoundry-auto-reconfiguration-context.xml</param-value></context-param>
<filter>
<filter-name>CharacterEncodingFilter</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>
<filter-name>HttpMethodFilter</filter-name>
<filter-class>org.springframework.web.filter.HiddenHttpMethodFilter</filter-class>
</filter>
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter>
<filter-name>Spring OpenEntityManagerInViewFilter</filter-name>
<filter-class>org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>CharacterEncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>HttpMethodFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>Spring OpenEntityManagerInViewFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- Creates the Spring Container shared by all Servlets and Filters -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>
<listener>
<listener-class>
org.springframework.security.web.session.HttpSessionEventPublisher
</listener-class>
</listener>
<!-- Handles Spring requests -->
<servlet>
<servlet-name>kadjoukor</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>WEB-INF/spring/webmvc-config.xml classpath:META-INF/cloud/cloudfoundry-auto-reconfiguration-context.xml</param-value></init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>kadjoukor</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>30</session-timeout><!-- TODO -->
</session-config>
<context-param><param-name>contextInitializerClasses</param-name><param-value>org.cloudfoundry.reconfiguration.spring.CloudApplicationContextInitializer</param-value></context-param></web-app>
Here is the content of the WEB-INF/libs directory:
activation-1.1.1.jar 67.8K
antlr-2.7.6.jar 433.0K
aopalliance-1.0.jar 4.4K
asm-3.3.1.jar 42.6K
aspectjrt-1.7.0.RC1.jar 113.5K
aspectjweaver-1.7.0.RC1.jar 1.7M
auto-reconfiguration-0.6.5.jar 693.3K
cglib-2.2.2.jar 280.5K
cglib-nodep-2.2.2.jar 319.3K
commons-beanutils-1.8.3.jar 226.6K
commons-codec-1.5.jar 71.4K
commons-collections-3.2.1.jar 561.9K
commons-dbcp-1.3.jar 145.3K
commons-digester-2.1.jar 192.2K
commons-fileupload-1.2.2.jar 58.2K
commons-io-2.1.jar 159.3K
commons-lang3-3.1.jar 308.4K
commons-logging-1.0.4.jar 37.1K
commons-pool-1.5.6.jar 98.1K
dom4j-1.6.1.jar 306.5K
ehcache-core-2.6.0.jar 1.3M
flexjson-2.1.jar 79.2K
guava-11.0.2.jar 1.6M
hamcrest-core-1.1.jar 74.8K
hibernate-commons-annotations-3.2.0.Final.jar 69.6K
hibernate-core-3.6.9.Final.jar 3.0M
hibernate-entitymanager-3.6.9.Final.jar 416.3K
hibernate-jpa-2.0-api-1.0.1.Final.jar 100.3K
hibernate-validator-4.2.0.Final.jar 358.0K
httpclient-4.1.2.jar 344.0K
httpcore-4.1.2.jar 177.0K
imgscalr-lib-4.2.jar 27.2K
jackson-core-asl-1.9.9.jar 226.7K
jackson-mapper-asl-1.9.9.jar 762.0K
java-xmlbuilder-0.4.jar 18.1K
javassist-3.12.0.GA.jar 618.5K
javassist-3.16.1-GA.jar 643.9K
javax.inject-1.jar 2.4K
jcl-over-slf4j-1.6.4.jar 16.9K
jets3t-0.9.0.jar 527.1K
jmimemagic-0.1.2.jar 44.5K
joda-time-2.1.jar 557.1K
jsr305-1.3.9.jar 32.2K
jstl-api-1.2.jar 29.8K
jstl-impl-1.2.jar 382.8K
jta-1.1.jar 14.7K
junit-dep-4.8.2.jar 213.2K
log4j-1.2.16.jar 470.2K
mail-1.4.3.jar 451.3K
mysema-commons-lang-0.2.4.jar 11.8K
mysql-connector-java-5.1.18.jar 771.4K
ognl-3.0.5.jar 222.5K
oro-2.0.8.jar 63.7K
prettytime-1.0.8.Final.jar 65.4K
querydsl-core-2.9.0.jar 367.3K
querydsl-jpa-2.9.0.jar 93.3K
slf4j-api-1.6.4.jar 25.4K
slf4j-log4j12-1.6.4.jar 9.5K
spring-aop-3.2.0.RELEASE.jar 327.0K
spring-aspects-3.2.0.RELEASE.jar 68.2K
spring-beans-3.2.0.RELEASE.jar 590.6K
spring-context-3.2.0.RELEASE.jar 834.0K
spring-context-support-3.2.0.RELEASE.jar 124.1K
spring-core-3.2.0.RELEASE.jar 842.8K
spring-data-commons-core-1.3.0.RELEASE.jar 215.0K
spring-data-jpa-1.1.0.RELEASE.jar 129.8K
spring-expression-3.2.0.RELEASE.jar 189.2K
spring-jdbc-3.2.0.RELEASE.jar 391.6K
spring-js-resources-2.2.1.RELEASE.jar 4.3M
spring-orm-3.2.0.RELEASE.jar 383.0K
spring-security-acl-3.1.2.RELEASE.jar 77.7K
spring-security-config-3.1.2.RELEASE.jar 198.9K
spring-security-core-3.1.2.RELEASE.jar 332.1K
spring-security-taglibs-3.1.2.RELEASE.jar 20.3K
spring-security-web-3.1.2.RELEASE.jar 245.2K
spring-social-core-1.0.2.RELEASE.jar 113.7K
spring-social-facebook-1.0.2.RELEASE.jar 117.2K
spring-social-web-1.0.2.RELEASE.jar 18.0K
spring-tx-3.2.0.RELEASE.jar 235.3K
spring-web-3.2.0.RELEASE.jar 609.7K
spring-webmvc-3.2.0.RELEASE.jar 621.0K
thymeleaf-2.0.14.jar 677.9K
thymeleaf-extras-tiles2-1.0.0-beta3-SNAPSHOT.jar 46.7K
thymeleaf-spring3-2.0.14.jar 161.9K
tiles-api-2.2.2.jar 35.1K
tiles-core-2.2.2.jar 157.2K
tiles-jsp-2.2.2.jar 49.6K
tiles-servlet-2.2.2.jar 58.3K
tiles-template-2.2.2.jar 23.9K
validation-api-1.0.0.GA.jar 46.3K
xercesImpl-2.7.1.jar 1.1M
xml-apis-1.0.b2.jar 106.8K
xmlParserAPIs-2.0.2.jar 76.6K
It seems a cloudfoundry jar library is missing from the above list. Can anyone please let me know which one that is?
Also, what I am getting wrong that could prevent spring profiles from working?
If you have a package (or pseudo package like /META-INF/cloud) in more than one location on your classpath (e.g. two jar files) then depending on the order the class loader decides to load them, they can hide each other. In particular this happens when using classpath:/... paths to load resources. You can sometimes use classpath*:/... but in this case that option may not be open. The cloudfoundry autoconfig jar contains /META-INF/cloud and it is being hidden by your app. The Spring framework runtime agent adds the classpath:/... path to your web.xml, so unless you want to add an explicit classpath*:/... the best thing you can do is move the stuff you have in /META-INF/cloud to a different location.
I am trying to activate one set of properties files for one Spring profile and another set for another Spring profile as follows:
<beans profile="cloud">
<context:property-placeholder location="classpath*:META-INF/spring/cloud/*.properties" />
</beans>
<beans profile="default">
<context:property-placeholder location="classpath*:META-INF/spring/default/*.properties" />
</beans>
I have the corresponding and appropriate directory structure in my src/main/resources folder.
I have a simple #Value("${application.url}") in one of my services and I systematically get the following error:
Error creating bean with name 'mailerServiceImpl': Injection of
autowired dependencies failed; nested exception is
org.springframework.beans.factory.Be anCreationException: Could not
autowire field: private java.lang.String
com.kadjoukor.service.MailerServiceImpl.websiteContext; nested
exception is java.lang.IllegalArgumentException: Could not resolve
placeholder 'application.url' in string value "${application.url}"
Note that I have tried adding a spring.profiles.active init-param to my web.xml. It doesn't make any difference...
I am not sure what I am getting wrong. Can anyone please provide advice?
EDIT 1: Could it matter that the above snippets of configuration are located at the bottom of the configuration file?
EDIT 2: Here is the output of my web.xml:
<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="3.0" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" metadata-complete="true">
<display-name>kadjoukor</display-name>
<description>Roo generated kadjoukor application</description>
<!-- Enable escaping of form submission contents -->
<context-param>
<param-name>defaultHtmlEscape</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:META-INF/spring/applicationContext*.xml classpath:META-INF/cloud/cloudfoundry-auto-reconfiguration-context.xml</param-value></context-param>
<filter>
<filter-name>CharacterEncodingFilter</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>
<filter-name>HttpMethodFilter</filter-name>
<filter-class>org.springframework.web.filter.HiddenHttpMethodFilter</filter-class>
</filter>
<filter>
<filter-name>springSecurityFilterChain</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>
<filter>
<filter-name>Spring OpenEntityManagerInViewFilter</filter-name>
<filter-class>org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>CharacterEncodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>HttpMethodFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>springSecurityFilterChain</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>Spring OpenEntityManagerInViewFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- Creates the Spring Container shared by all Servlets and Filters -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>
<listener>
<listener-class>
org.springframework.security.web.session.HttpSessionEventPublisher
</listener-class>
</listener>
<!-- Handles Spring requests -->
<servlet>
<servlet-name>kadjoukor</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>WEB-INF/spring/webmvc-config.xml classpath:META-INF/cloud/cloudfoundry-auto-reconfiguration-context.xml</param-value></init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>kadjoukor</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>30</session-timeout><!-- TODO -->
</session-config>
<context-param><param-name>contextInitializerClasses</param-name><param-value>org.cloudfoundry.reconfiguration.spring.CloudApplicationContextInitializer</param-value></context-param></web-app>
and here is the contents of the WEB-INF/libs directory:
activation-1.1.1.jar 67.8K
antlr-2.7.6.jar 433.0K
aopalliance-1.0.jar 4.4K
asm-3.3.1.jar 42.6K
aspectjrt-1.7.0.RC1.jar 113.5K
aspectjweaver-1.7.0.RC1.jar 1.7M
auto-reconfiguration-0.6.5.jar 693.3K
cglib-2.2.2.jar 280.5K
cglib-nodep-2.2.2.jar 319.3K
commons-beanutils-1.8.3.jar 226.6K
commons-codec-1.5.jar 71.4K
commons-collections-3.2.1.jar 561.9K
commons-dbcp-1.3.jar 145.3K
commons-digester-2.1.jar 192.2K
commons-fileupload-1.2.2.jar 58.2K
commons-io-2.1.jar 159.3K
commons-lang3-3.1.jar 308.4K
commons-logging-1.0.4.jar 37.1K
commons-pool-1.5.6.jar 98.1K
dom4j-1.6.1.jar 306.5K
ehcache-core-2.6.0.jar 1.3M
flexjson-2.1.jar 79.2K
guava-11.0.2.jar 1.6M
hamcrest-core-1.1.jar 74.8K
hibernate-commons-annotations-3.2.0.Final.jar 69.6K
hibernate-core-3.6.9.Final.jar 3.0M
hibernate-entitymanager-3.6.9.Final.jar 416.3K
hibernate-jpa-2.0-api-1.0.1.Final.jar 100.3K
hibernate-validator-4.2.0.Final.jar 358.0K
httpclient-4.1.2.jar 344.0K
httpcore-4.1.2.jar 177.0K
imgscalr-lib-4.2.jar 27.2K
jackson-core-asl-1.9.9.jar 226.7K
jackson-mapper-asl-1.9.9.jar 762.0K
java-xmlbuilder-0.4.jar 18.1K
javassist-3.12.0.GA.jar 618.5K
javassist-3.16.1-GA.jar 643.9K
javax.inject-1.jar 2.4K
jcl-over-slf4j-1.6.4.jar 16.9K
jets3t-0.9.0.jar 527.1K
jmimemagic-0.1.2.jar 44.5K
joda-time-2.1.jar 557.1K
jsr305-1.3.9.jar 32.2K
jstl-api-1.2.jar 29.8K
jstl-impl-1.2.jar 382.8K
jta-1.1.jar 14.7K
junit-dep-4.8.2.jar 213.2K
log4j-1.2.16.jar 470.2K
mail-1.4.3.jar 451.3K
mysema-commons-lang-0.2.4.jar 11.8K
mysql-connector-java-5.1.18.jar 771.4K
ognl-3.0.5.jar 222.5K
oro-2.0.8.jar 63.7K
prettytime-1.0.8.Final.jar 65.4K
querydsl-core-2.9.0.jar 367.3K
querydsl-jpa-2.9.0.jar 93.3K
slf4j-api-1.6.4.jar 25.4K
slf4j-log4j12-1.6.4.jar 9.5K
spring-aop-3.2.0.RELEASE.jar 327.0K
spring-aspects-3.2.0.RELEASE.jar 68.2K
spring-beans-3.2.0.RELEASE.jar 590.6K
spring-context-3.2.0.RELEASE.jar 834.0K
spring-context-support-3.2.0.RELEASE.jar 124.1K
spring-core-3.2.0.RELEASE.jar 842.8K
spring-data-commons-core-1.3.0.RELEASE.jar 215.0K
spring-data-jpa-1.1.0.RELEASE.jar 129.8K
spring-expression-3.2.0.RELEASE.jar 189.2K
spring-jdbc-3.2.0.RELEASE.jar 391.6K
spring-js-resources-2.2.1.RELEASE.jar 4.3M
spring-orm-3.2.0.RELEASE.jar 383.0K
spring-security-acl-3.1.2.RELEASE.jar 77.7K
spring-security-config-3.1.2.RELEASE.jar 198.9K
spring-security-core-3.1.2.RELEASE.jar 332.1K
spring-security-taglibs-3.1.2.RELEASE.jar 20.3K
spring-security-web-3.1.2.RELEASE.jar 245.2K
spring-social-core-1.0.2.RELEASE.jar 113.7K
spring-social-facebook-1.0.2.RELEASE.jar 117.2K
spring-social-web-1.0.2.RELEASE.jar 18.0K
spring-tx-3.2.0.RELEASE.jar 235.3K
spring-web-3.2.0.RELEASE.jar 609.7K
spring-webmvc-3.2.0.RELEASE.jar 621.0K
thymeleaf-2.0.14.jar 677.9K
thymeleaf-extras-tiles2-1.0.0-beta3-SNAPSHOT.jar 46.7K
thymeleaf-spring3-2.0.14.jar 161.9K
tiles-api-2.2.2.jar 35.1K
tiles-core-2.2.2.jar 157.2K
tiles-jsp-2.2.2.jar 49.6K
tiles-servlet-2.2.2.jar 58.3K
tiles-template-2.2.2.jar 23.9K
validation-api-1.0.0.GA.jar 46.3K
xercesImpl-2.7.1.jar 1.1M
xml-apis-1.0.b2.jar 106.8K
xmlParserAPIs-2.0.2.jar 76.6K
Base on the https://cloudfoundry.atlassian.net/browse/CF-132 bug, in order to have the cloud profile work, you would need a ContextLoaderInitializer. So I would suggest you to create a context file, even leave it empty if you have to, to make the cloud profile work.
I am trying to use spring-security
Before all of the configuration
http://localhost:9090/app/login2.xhtml
request, works as i expected.
I added a controller:
#Controller
#RequestMapping("/auth")
public class LoginController {
#RequestMapping(value = "/login", method = RequestMethod.GET)
public String getLoginPage(#RequestParam(value="error", required=false) boolean error,
ModelMap model) {
return "login2.xhtnml";
}
}
I have in web.xml:
<servlet>
<servlet-name>spring</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:META-INF/spring-servlet.xml
</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
With this configuration when i call
http://localhost:9090/app/login2.xhtml
Error comes
WARN org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/app/login2.xhtml] in DispatcherServlet with name 'spring'
BUT when i change configuration mapping to
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>/app/*</url-pattern>
</servlet-mapping>
http://localhost:9090/app/login2.xhtml works as i expected
but
http://localhost:9090/app/auth/login
gives no error, no exception, no redirection, i think dispatcher servlet can not know about this request.
http://localhost:9090/app/app/auth/login
works with
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>/app/*</url-pattern>
</servlet-mapping>
My understanding:
dispatcher servlet use "http://localhost:9090/" as base for searching login2.xhtml
and use "http://localhost:9090/app" for /auth/login URL.
I do not know where to set this, and why they are different.
Have you added the SpringSecurityFilterChain to the web.xml?
<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>
Could you past the registered "Request Bindings" if the container starts (from the logfile)?
I am using springs framework with Tomcat 7 & MySQL. I am using UTF-8 encoding to submit form data for Local Language. This works fine using post through a JSP. However, when using Ajax Based Form submission it shows junk characters as request parameters in server.
Please let me know if I am missing anything..
** My Ajax Code**
xmlHttp.open("POST", "viewTeluguScript.htm", true);
//xmlHttp.setRequestHeader("Content-type", "multipart/form-data;charset=UTF-8");
xmlHttp.setRequestHeader("Content-length", parameters.length);
// xmlHttp.setRequestHeader("Content-Type", "text/html;charset=UTF-8");
xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded;charset=UTF-8");
//xmlHttp.setRequestHeader("pageEncoding","UTF-8");
//xmlHttp.setRequestHeader("accept-charset","UTF-8");
xmlHttp.setRequestHeader("content-language","tel");
xmlHttp.setRequestHeader("Connection", "close");
xmlHttp.send(parameters);
**My Controller code**
public ModelAndView viewTeluguScript(HttpServletRequest request, HttpServletResponse response) throws SQLException, CannotGetJdbcConnectionException, Exception {
//textInfo = java.net.URLDecoder.decode(request.getParameter("teluguText"), "UTF-8");
textInfo = request.getParameter("teluguText");
/* StringBuffer jb = new StringBuffer();
String line = null;
try {
BufferedReader reader = request.getReader();
while ((line = reader.readLine()) != null)
jb.append(line);
} catch (Exception e) {
}
System.out.println("request is :::: "+jb.toString());*/
ModelAndView mv = new ModelAndView("viewQuestions");
//request.getSession().setAttribute("workingModule", "questions");
return mv;
}
enter code here
**My web.xml**
<?xml version="1.0" encoding="UTF-8"?>
<web-app 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">
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/applicationContext-security.xml
classpath:applicationContext-common-business.xml
classpath:applicationContext-common-authorization.xml
</param-value>
</context-param>
<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>
<locale-encoding-mapping-list>
<locale-encoding-mapping>
<locale>en</locale>
<encoding>UTF-8</encoding>
</locale-encoding-mapping>
<locale-encoding-mapping>
<locale>tel</locale>
<encoding>UTF-8</encoding>
</locale-encoding-mapping>
</locale-encoding-mapping-list>
<filter-mapping>
<filter-name>encodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<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>org.springframework.security.web.session.HttpSessionEventPublisher</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>g2l</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<!--<load-on-startup>2</load-on-startup>-->
</servlet>
<servlet-mapping>
<servlet-name>g2l</servlet-name>
<url-pattern>*.htm</url-pattern>
</servlet-mapping>
<!-- <session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>redirect.jsp</welcome-file>
</welcome-file-list>-->
</web-app>
try adding a content-encoding http header
your browser uses Unicode to represent data to display. Resources coming from a web server can optionally have encoding information attached in http header.
If there is a content-encoding header, the browser converts the resource to the internal unicode representation using encoding from the response header. If there is no content-encoding header, the browser assumes, that the file encoding is the same as the page which requested the resource.