Displaying keyword search results 1 - 10
Created by Fang on January 10, 2014 14:07:20 Last update: January 10, 2014 14:07:20
An example project with Spring MVC and Apache Tiles. List of files:
./pom.xml ./src/main/webapp/WEB-INF/web.xml..../pom.xml :
<?xml version="1.0" encoding="UTF-8"?> <pro..../src/main/webapp/WEB-INF/web.xml :
<?xml version="1.0" encoding="UTF-8"?> <web-app..../src/main/webapp/WEB-INF/applicationContext.xml :
<?xml version="1.0" encoding="UTF-8"?> <beans x..../src/main/webapp/WEB-INF/spring-servlet.xml :
<?xml version="1.0" encoding="UTF-8"?> <beans x..../src/main/webapp/WEB-INF/tiles-definitions.xml :
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYP..../src/main/webapp/WEB-INF/jsp/template.jsp :
<!DOCTYPE html> <%@ page pageEncoding="UTF-8" %..../src/main/java/com/example/MyController.java :
package com.example; import javax.servlet.S...
Created by Fang on January 06, 2014 12:22:17 Last update: January 06, 2014 12:22:17
Add <mvc:default-servlet-handler/> to the spring servlet config ( spring-servlet.xml ?) so that static files can be handled by the default servlet handler. This is a full configuration file for example:
<?xml version="1.0" encoding="UTF-8"?> <beans x...
Created by Fang on August 28, 2013 20:37:17 Last update: August 28, 2013 20:37:17
The default extension for JSF facelet files is .xhtml, which looks so out-of-date these days. I wanted to change the extension from .xhtml to .html, to make it look more modern, even though I still use JSF xhtml in reality. This didn't work ( web.xml ):
<servlet-mapping> <servlet-name>Faces Ser...Using the servlet-mapping config without the context-param works, given that the actual file extensions are still .xhtml . But the caveat is, if you request the .xhtml file directly, it will be sent to the browser unprocessed. This worked:
<servlet-mapping> <servlet-name>Faces Ser...I'm using myfaces 2.1.11.
Created by Dr. Xi on March 21, 2013 19:47:46 Last update: March 22, 2013 12:30:27
It's normal practice to import types from an external xsd file in WSDL like this:
<wsdl:types> <xsd:schema xmlns:xsd="htt...When you use <dynamic-wsdl> and have Commons XMLSchema on the class path, Spring-WS inlines the xsd in the wsdl. But that doesn't happen when you use <static-wsdl> . You can define a SimpleXsdSchema bean to expose the xsd:
Created by Dr. Xi on April 19, 2012 10:10:08 Last update: April 19, 2012 10:11:06
The default servlet for Tomcat is declared in $CATALINA_HOME/conf/web.xml :
<servlet> <servlet-name>default</servle...Therefore, static content is rendered by the default configuration unless you override it with your own definitions. If you want to allow directory listing, just change the listing parameter to true :
<init-param> <param-name>listings</para...Change the welcome-file-list to display a default page in lieu of a directory listing:
<welcome-file-list> <welcome-file>home.xhtml</...Welcome pages are defined at the Web application level.
Created by Fang on February 23, 2012 14:25:57 Last update: March 01, 2012 13:53:59
Some example snippets for Spring message configuration and usage. To configure a message source in Spring context (basename=messages):
<bean id="messageSource" class="org.springf...Locale change interceptor can also be setup with:
<?xml version="1.0" encoding="UTF-8"?> <beans x...The messages file should be named messages.properties (or messages_en.properties , etc.) and located on CLASSPATH , for example: WEB-INF/classes . To use a message resource in JSP:
<%@ taglib prefix="spring" uri="http://www.springf...
Created by James on February 02, 2012 16:00:15 Last update: February 02, 2012 16:00:15
Video for Everybody seems to be a generic way to embed video in a web page, even without flash. This code snippet comes from that site.
<!-- first try HTML5 playback: if serving as XML, ...
Created by Dr. Xi on February 01, 2012 12:55:28 Last update: February 01, 2012 12:55:28
You can define environment variables in the Tomcat context.xml file like this:
<?xml version="1.0" encoding="UTF-8"?> <Context...which is equivalent to the following in web.xml :
<env-entry> <env-entry-name>varName</env-entr...In Java code, the variable can be looked up like this:
// import javax.naming.Context; // import javax...
Created by Fang on January 31, 2012 15:40:34 Last update: January 31, 2012 15:41:28
This is a simple Hello World application with Spring 3 MVC. Like the default Apache HTTPd welcome page, it displays " It works! " when successfully deployed. The sole purpose is to show the minimum elements needed to setup Spring 3 MVC. I use Maven since it's so much easier than downloading the dependencies manually. Directory layout:
./src ./src/main ./src/main/webapp ./src/...pom.xml :
<?xml version="1.0" encoding="UTF-8"?> <project...WEB-INF/web.xml :
<?xml version="1.0" encoding="UTF-8"?> <web-app...WEB-INF/applicationContext.xml (empty, but needed):
<?xml version="1.0" encoding="UTF-8"?> <beans x...WEB-INF/spring-servlet.xml :
<?xml version="1.0" encoding="UTF-8"?> <beans x...WEB-INF/jsp/home.jsp :
<!DOCTYPE html> <html> <head> <title>H...Build with:
mvn clean packageThe resulting webapp is target/springmvc.war .
Created by Fang on January 31, 2012 13:57:56 Last update: January 31, 2012 15:04:29
These are the minimum steps to configure Spring MVC in web.xml : Bootstrap Spring MVC by registering ContextLoaderListener :
<listener> <listener-class> org.springfra...Register the DispatcherServlet :
<servlet> <servlet-name>spring</servlet-name> ...Add servlet-mapping :
<servlet-mapping> <servlet-name>spring</servle...Configure DispatcherServlet with WEB-INF/spring-servlet.xml , which configures WebApplicationContext specific to this servlet.
<?xml version="1.0" encoding="UTF-8"?> <beans x...Optionally, use context-param in web.xml to configure the global WebApplicationContext :
<!-- XmlWebApplicationContext is the default, so t...If you omit this section, you have to create file WEB-INF/applicationContext.xml , even if it's empty. This is the full web.xml :
<?xml version="1.0" encoding="UTF-8"?> <web-app...