Issue tiles (Could not resolve view with name...) - spring-mvc

I am working with Spring MVC. My application was ok before inserting tiles, now I keep receiving the error message as:
javax.servlet.ServletException: Could not resolve view with name '/sisStudent' in servlet with name 'mvc-dispatcher'
org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1190)
org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:992)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:939)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:936)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:827)
javax.servlet.http.HttpServlet.service(HttpServlet.java:734)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812)
javax.servlet.http.HttpServlet.service(HttpServlet.java:847)
My tiles.xml is:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE tiles-definitions PUBLIC
"-//Apache Software Foundation//DTD Tiles Configuration 3.0//EN"
"http://tiles.apache.org/dtds/tiles-config_3_0.dtd">
<tiles-definitions>
<definition name="base.definition" template="/WEB-INF/jsp/layout.jsp">
<put-attribute name="title" value="" />
<put-attribute name="header" value="/WEB-INF/jsps/header.jsp" />
<put-attribute name="menu" value="/WEB-INF/jsps/menu.jsp" />
<put-attribute name="body" value="" />
<!-- put-attribute name="footer" value="/WEB-INF/jsps/footer.jsp" /> -->
</definition>
<definition name="sisStudent" extends="base.definition">
<put-attribute name="title" value="SIS Students" />
<put-attribute name="body" value="/WEB-INF/jsps/sisStudent.jsp" />
</definition>
</tiles-definitions>
My spring-servlet.xml is:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
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-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<context:component-scan base-package="au.edu.nsw.det.tls.tar.sis.controller" />
<!--
bean id="tilesViewResolver"
class="org.springframework.web.servlet.view.UrlBasedViewResolver">
property name="prefix"> <value>/WEB-INF/jsps/</value> </property>
<property name="suffix"> <value>.jsp</value> </property> <property
name="viewClass"> <value>
org.springframework.web.servlet.view.tiles3.TilesView</value>
</property> </bean>
-->
<!-- bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix">
<value>/WEB-INF/jsps/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean -->
<bean id="viewResolver"
class="org.springframework.web.servlet.view.UrlBasedViewResolver">
<property name="viewClass">
<value> org.springframework.web.servlet.view.tiles3.TilesView</value>
</property>
</bean>
<bean id="tilesConfigurer"
class="org.springframework.web.servlet.view.tiles3.TilesConfigurer">
<property name="definitions">
<list>
<value>/WEB-INF/tiles.xml</value>
</list>
</property>
</bean>
</beans>
My controller is:
#Controller
// #RequestMapping("/studentSearch")
public class StudentSearchController {
#Autowired
StudentService studentService;
// #RequestMapping(value="/StudentSearchById", method = RequestMethod.GET)
// public ModelAndView searchById(#PathVariable Long studentId) {
#RequestMapping (value="/openStudentSearchScreen", method = RequestMethod.GET)
public ModelAndView openCourseSearchScreen(){
ModelAndView modelAndView = new ModelAndView("/sisStudent");
return modelAndView;
}
}
Any ideas?
Thank you in advance!

In your ModelAndView constructor remove the leading / so it should be
#RequestMapping (value="/openStudentSearchScreen", method = RequestMethod.GET)
public ModelAndView openCourseSearchScreen(){
ModelAndView modelAndView = new ModelAndView("sisStudent");
return modelAndView;
}
OTOH Insted of ModelAndView you can use String
#RequestMapping (value="/openStudentSearchScreen", method = RequestMethod.GET)
public String openCourseSearchScreen(){
return "sisStudent";//Tiles definition name
}
If you want to add some model attribute
#RequestMapping (value="/openStudentSearchScreen", method = RequestMethod.GET)
public String openCourseSearchScreen(Model model){
model.addAttribute("<name of the attribute>",<value as object>);
return "sisStudent";//Tiles definition name
}

Related

Spring framework No adapter for handler

I am upgrading Spring framework from very old version to 5.3 - I made updated to controller and configuration file. I am getting "javax.servlet.ServletException: No adapter for handler for Controller" error.
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:oxm="http://www.springframework.org/schema/oxm"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-3.1.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
http://www.springframework.org/schema/oxm
http://www.springframework.org/schema/oxm/spring-oxm-3.1.xsd">
<context:component-scan base-package="abc.controller,abc.bean,abc.bean.command,abc.validator" />
<context:annotation-config />
<mvc:annotation-driven />
<bean class="org.springframework.web.servlet.view.BeanNameViewResolver" />
<!-- Controllers -->
<bean id="uploadFormController" class="abc.controller.UploadFormController">
<property name="mailSender"><ref bean="mailSender"/></property>
<property name="message"><ref bean="uploadConfirmationEmail"/></property>
<property name="submissionDao"><ref bean="submissionDao"/></property>
<property name="providerDao"><ref bean="providerDao"/></property>
</bean>
<bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="urlMap">
</property>
<property name="interceptors">
<list>
<ref bean="securityInterceptor"/>
</list>
</property>
<property name="mappings">
<props>
<prop key="upload.html">starSiSpreadsheetUploadFormController</prop>
</props>
</property>
</bean>
<bean id="securityInterceptor"
class="abc.interceptor.SecurityInterceptor">
<property name="defaultUser"><value>${abc.defaultUser}</value></property>
</bean>
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass">
<value>org.springframework.web.servlet.view.JstlView</value>
</property>
<property name="prefix"><value>/jsp/</value></property>
<property name="suffix"><value>.jsp</value></property>
</bean>
</beans>`
package abc.controller;
#Controller
#RequestMapping("/upload.html")
public class UploadFormController {
#Autowired
private SpreadsheetUpload bean; //CommandClass
#Autowired
private MailSender mailSender;
#Autowired
private SimpleMailMessage message;
#Autowired
private SubmissionDAO submissionDao;
#Autowired
private ProviderDAO providerDao;
protected String onSubmit(HttpServletRequest request,
HttpServletResponse response, BindException errors)
throws Exception
{
// let's see if there's a provider
if (bean.getProvider() == null)
{
log.info("No provider selected.");
throw new DataEntryException("No provider selected. ");
}
return "redirect:upload.html";
}
protected Map referenceData(HttpServletRequest request) throws Exception
{
// TODO - switch code over to using LDAP queries
HttpSession session = request.getSession();
//Logic goes here..
Map map = new HashMap();
map.put("admin", admin);
return map;
}
}
Could someone take a look and help me on this? I have been trying since last two days and no luck so far. Thank you!
There is nothing wrong in my code. I have another method called "OnSubmit" which is causing the problem.

Spring mvc redirect to different application on different jvm

My requirement is to redirection between two different apps in different JVMs. And also transfer data between the two. I tried using Flash Attributes, but in the controller, the attributes are null. I tried creating an interceptor also, but even there the flash attributes are null. Can anyone help me on how to pass attributes between two different applications?
Here is my code:
poc1 - calling application
dispatcher-servlet.xml
<context:component-scan base-package="controller" />
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass"
value="org.springframework.web.servlet.view.JstlView" />
<property name="prefix">
<value>/WEB-INF/views/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
<bean name="flashMapManager" class="org.springframework.web.servlet.support.SessionFlashMapManager" />
<mvc:annotation-driven />
</beans>
Controller.java
#RequestMapping(value = "add", method = RequestMethod.POST)
public String add(#ModelAttribute("customer") Customer customer,
final RedirectAttributes redirectAttributes) {
redirectAttributes.addFlashAttribute("customer", customer);
redirectAttributes.addFlashAttribute("message", "Added successfully.");
return "redirect:http://localhost:8080/poc2";
}
poc2 - called application
dispatcher-servlet.xml
<context:component-scan base-package="controller" />
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass"
value="org.springframework.web.servlet.view.JstlView" />
<property name="prefix">
<value>/WEB-INF/views/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
<bean name="flashMapManager"
class="org.springframework.web.servlet.support.SessionFlashMapManager" />
<!-- <bean id="handlerMapping" class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping">
<property name="interceptors"> <list> <ref bean="requestInterceptor" /> </list>
</property> </bean> -->
<bean id="requestInterceptor" class="RequestInterceptor" />
<mvc:annotation-driven />
<mvc:interceptors>
<ref bean="requestInterceptor" />
</mvc:interceptors>
</beans>
Controller.java
#RequestMapping(value = "/", method = RequestMethod.GET)
public ModelAndView index(Model model, HttpServletRequest request,
HttpSession session) {
Map<String, ?> inputFlashMap = RequestContextUtils
.getInputFlashMap(request);
Customer cust1 = (Customer) model.asMap().get("customer");
Customer cust = (Customer) inputFlashMap.get("customer");
ModelAndView modelMap = new ModelAndView("showCustomer");
System.out.println("Calling controller");
return modelMap;
}
you can use this,
Using just redirectAttributes.addFlashAttribute(...) -> "redirect:..." worked as well, didn't have to "reinsert" the model attribute.

Spring mvc: Controller Result resent to RequestMappingHandlerMapping

I have an abstract Spring Controller class extended by various controllers.
Example method:
#Override
#RequestMapping(value = { "/", "" }, method = RequestMethod.GET)
public String getAllAsView(#RequestParam(required = false) boolean ajax,
Model m) {
String mapping = elementClass.getSimpleName();
m.addAttribute(mapping + "List", getAll());
return mapping + "All" + (ajax ? "Ajax" : "");
}
These are the relevant definitions in my view.xml:
<definition name="maintemplate" template="/WEB-INF/views/main_template.jsp">
<put-attribute name="top" value="/WEB-INF/views/header.jsp" />
<put-attribute name="side" value="/WEB-INF/views/menu.jsp" />
</definition>
<definition name="ajaxtemplate" template="/WEB-INF/views/ajax_template.jsp">
<put-attribute name="top" value="/WEB-INF/views/header.jsp" />
</definition>
<definition name="PersonAll" extends="maintemplate">
<put-attribute name="content" value="/WEB-INF/views/personlist.jsp" />
</definition>
<definition name="PersonAllAjax" template="ajaxtemplate">
<put-attribute name="content" value="/WEB-INF/views/personlist.jsp" />
</definition>
With the ajax parameter only the body content is to return.
Everything works fine without the ajax parameter.
But with the Ajax parameter the return string is used for a new Controller request.
This is the Log:
DEBUG: org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping - Looking up handler method for path /person/6
TRACE: org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod - Invoking [PersonController.getAsView] method with arguments [6, true, {}]
WARN : de.kreth.clubhelperbackend.aspects.DaoLoggerAspect - de.kreth.clubhelperbackend.dao.PersonDao.getById(6) ==> 6: M Kreth
TRACE: org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod - Method [getAsView] returned [PersonGetAjax]
DEBUG: org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping - Looking up handler method for path /person/ajaxtemplate
This is the servlet-context.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/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
<context:component-scan base-package="de.kreth.clubhelperbackend" />
<mvc:annotation-driven>
<mvc:message-converters>
<bean
class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
<property name="objectMapper">
<bean
class="org.springframework.http.converter.json.Jackson2ObjectMapperFactoryBean">
<property name="dateFormat">
<bean class="java.text.SimpleDateFormat">
<constructor-arg type="java.lang.String"
value="dd/MM/yyyy HH:mm:ss.SSS Z"></constructor-arg>
</bean>
</property>
</bean>
</property>
</bean>
</mvc:message-converters>
</mvc:annotation-driven>
<mvc:resources mapping="/resources/**" location="/resources/" />
<bean
class="org.springframework.web.servlet.view.ContentNegotiatingViewResolver" />
<bean class="org.springframework.web.servlet.view.tiles2.TilesViewResolver">
<property name="order" value="1" />
</bean>
<bean class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
<property name="definitions">
<list>
<value>/WEB-INF/views/**/views.xml</value>
</list>
</property>
</bean>
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="order" value="2" />
<property name="prefix" value="/WEB-INF/views/" />
<property name="suffix" value=".jsp" />
</bean>
I am stuck finding out what is happening here. I changed the template name and the new name was used for the request.
The problem came up, after I changed nearly all xml files in project. I inserted Doctype tag and changed schema definitions and stuff. Because that caused heavy problems I stepped back to a working version. Before that, the ajax parameter worked.
Ah - and I updated to java-version 1.6.
Any ideas why spring uses the templatename "ajaxtemplate" as a new request and sends it back to the controller?
Best regards
Markus
Stupid mistake: never programm past midnight:
<definition name="PersonAllAjax" template="ajaxtemplate">
<put-attribute name="content" value="/WEB-INF/views/personlist.jsp" />
</definition>
must be
<definition name="PersonAllAjax" extends="ajaxtemplate">
<put-attribute name="content" value="/WEB-INF/views/personlist.jsp" />
</definition>

How can a Spring Webflow application be configured to use Xslt to render its viewstates

I would like my Spring Webflow app to render its views using XSLT. I managed to get a pure Spring MVC app to render with xslt by configuring an XSLTviewresolver and a controller method that returned an already prepared xml as a source.
But I'm not sure how to apply that to the webflow app.
I've added the configuration for the XSLT view resolver and set the view state to the xsl, then I call the controller method that returns the xml source in the on-render of the view state.So far I only get the xsl back as the output and not the transformed xml or even the raw xml.
EDIT
flow.xml-full
<?xml version="1.0" encoding="UTF-8"?>
<flow xmlns="http://www.springframework.org/schema/webflow"
<view-state id="messageChoice" view="start1">
<transition on="chooseA" to="messageA"/>
<transition on="chooseB" to="messageB"/>
</view-state>
<view-state id="messageA" view="messageA">
<transition on="start" to="messageChoice"/>
</view-state>
<view-state id="messageB" view="xsltview">
<on-render>
<evaluate expression="sampleController.viewXSLT(externalContext.getNativeRequest(),externalContext.getNativeResponse())" result="requestScope.xmlSource"/>
</on-render>
<transition on="start" to="messageChoice"/>
</view-state>
<end-state id="finish"/>
</flow>
controller-snippet
#RequestMapping(value="/viewxslt")
public ModelAndView viewXSLT(HttpServletRequest request,
HttpServletResponse response) throws IOException {
// builds absolute path of the XML file
String xmlFile = "/WEB-INF/xml/thexml.xml";
String contextPath = request.getSession().getServletContext().getRealPath(xmlFile);
String xmlFilePath = ""+contextPath + File.separator + xmlFile;
Source source = new StreamSource(new File(contextPath));
// adds the XML source file to the model so the XsltView can detect
ModelAndView model = new ModelAndView("xsltview");
model.addObject("xmlSource", source);
return model;
}
EDIT
flow-config-full
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
<context:annotation-config />
<context:component-scan base-package="com.genkey.derek" />
<mvc:view-controller path="/start" />
<mvc:view-controller path="/messageHome" />
<mvc:resources location="/" mapping="/resources/**" />
<faces:resources />
<bean class="org.springframework.webflow.mvc.servlet.FlowHandlerMapping">
<property name="flowRegistry" ref="flowRegistry" />
<property name="order" value="3" />
</bean>
<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"/>
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter"/>
<bean id="xsltviewresolver" class="org.springframework.web.servlet.view.xslt.XsltViewResolver">
<property name="order" value="1"/>
<property name="sourceKey" value="xmlSource"/>
<property name="viewClass" value="org.springframework.web.servlet.view.xslt.XsltView"/>
<property name="viewNames">
<array>
<value>xsltview</value>
</array>
</property>
<property name="prefix" value="/WEB-INF/xsl/" />
<property name="suffix" value=".xsl" />
</bean>
<bean id="viewFactoryCreator" class="org.springframework.webflow.mvc.builder.MvcViewFactoryCreator">
<property name="viewResolvers">
<list>
<ref bean="xsltviewresolver"/>
<ref bean="faceletsViewResolver" />
</list>
</property>
</bean>
<bean id="faceletsViewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver">
<property name="viewClass" value="org.springframework.faces.mvc.JsfView"/>
<property name="prefix" value="/WEB-INF/pages/" />
<property name="suffix" value=".xhtml" />
<property name="order">
<value>2</value>
</property>
</bean>
<bean class="org.springframework.faces.webflow.JsfFlowHandlerAdapter">
<property name="flowExecutor" ref="flowExecutor" />
</bean>
<webflow:flow-executor id="flowExecutor">
<webflow:flow-execution-listeners>
<webflow:listener ref="facesContextListener"/>
</webflow:flow-execution-listeners>
</webflow:flow-executor>
<webflow:flow-registry id="flowRegistry" flow-builder-services="flowBuilderServices" >
<webflow:flow-location path="WEB-INF/flows/startFlow.xml"/>
</webflow:flow-registry>
<faces:flow-builder-services id="flowBuilderServices" view-factory-creator="viewFactoryCreator" development="true" />
<bean id="facesContextListener" class="org.springframework.faces.webflow.FlowFacesContextLifecycleListener"/>
</beans>

How to load js and css file in Spring MVC 3 with tiles3

I am unable to load the Js and Css files in to jsp using Spring MVC 3 with tiles3. Can someone help me. Here the my configuration.
Project Folder Structure
-SpringWithTiles
----webapp
--------resouces
----------script
--------------js
---------------myscript.js
--------------css
---------------style.css
----WEB-INF
-------jsp
---------signIn.jsp
servlet.xml
<bean class="org.springframework.web.servlet.view.UrlBasedViewResolver" id="viewResolver">
<property name="viewClass">
<value>
org.springframework.web.servlet.view.tiles3.TilesView
</value>
</property>
</bean>
<bean id="tilesConfigurer"
class="org.springframework.web.servlet.view.tiles3.TilesConfigurer">
<property name="definitions">
<list>
<value>/WEB-INF/tiles.xml</value>
</list>
</property>
</bean>
<mvc:resources mapping="/resources/script/js/**" location="/webapp/resources/script/css" />
<mvc:resources mapping="/resources/script/css/**" location="/webapp/resources/script/js" />`
tiles.xml
<tiles-definitions>
<definition name="baseLayout" template="/WEB-INF/layout/simpleLayout.jsp">
<put-attribute name="title" value="" />
<put-attribute name="header" value="/WEB-INF/layout/header.jsp"/>
<put-attribute name="body" value="" />
<put-attribute name="footer" value="/WEB-INF/layout/footer.jsp" />
</definition>
<!-- <definition name="baseLayoutWithLeftPane" template="/jsp/layout
/layoutWithLeftPane.jsp">
<put-attribute name="title" value="Learn - Educate" />
<put-attribute name="header" value="/jsp/layout/header.jsp" />
<put-attribute name="navigation" value="/jsp/layout/navigation.jsp" />
<put-attribute name="body" value="" />
<put-attribute name="footer" value="/jsp/layout/footer.jsp" />
</definition>
<definition name="welcome" extends="baseLayoutWithLeftPane">
<put-attribute name="title" value="Learn - Educate" />
<put-attribute name="body" value="/jsp/home.jsp" />
</definition> -->
<definition name="siginIn" extends="baseLayout">
<put-attribute name="title" value="siginIn" />
<put-attribute name="body" value="/WEB-INF/jsp/siginIn.jsp" />
</definition>
web.xml
<servlet-mapping>
<servlet-name>babwitU</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>/index.jsp</welcome-file>
</welcome-file-list>
index.jsp
Click Here
Contoller.java
#RequestMapping("/redirectToSiginIn")
public ModelAndView siginIn(){
ModelAndView mav=new ModelAndView();
mav.setViewName("/siginIn");
return mav;
}
In servlet.xml change mapping like this location="/resources/script/css"
and give path from resources/fileNameToLoad where you want to load ur js or css
In location attribute give path from /resources/** not from /webapps/
The correct mapping should be:
<mvc:resources mapping="/resources/script/js/**" location="/resources/script/css" />
<mvc:resources mapping="/resources/script/css/**" location="/resources/script/js" />
The first / in the attribute location indicates the ${webappRoot} already.
My problem get resolved with following configuration.. thanks for all
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/j2ee" xmlns:web="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" id="WebApp_ID" version="2.4">
<display-name>babwitU</display-name>
<servlet>
<servlet-name>babwitU</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/coreJava.xml,/WEB-INF/home.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>babwitU</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>/index.jsp</welcome-file>
</welcome-file-list>
<!-- <listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener> -->
</web-app>
servelt.xml
<context:component-scan base-package="com.babwitU.life.dream.controller" />
<mvc:annotation-driven />
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<!-- <property name="location" value="classpath:jdbc.properties" /> -->
</bean>
<!-- <bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/jsp"></property>
<property name="suffix" value=".jsp"></property>
</bean> -->
<bean class="org.springframework.web.servlet.view.UrlBasedViewResolver" id="viewResolver">
<property name="viewClass">
<value>
org.springframework.web.servlet.view.tiles3.TilesView
</value>
</property>
</bean>
<bean id="tilesConfigurer"
class="org.springframework.web.servlet.view.tiles3.TilesConfigurer">
<property name="definitions">
<list>
<value>/WEB-INF/tiles.xml</value>
</list>
</property>
</bean>
<mvc:resources mapping="/resources/**" location="/resources/" />
controller.java
#RequestMapping(value ="redirectToSiginIn", method = RequestMethod.GET)
public ModelAndView viewSiginIn(){
ModelAndView mav=new ModelAndView();
mav.setViewName("siginIn");
return mav;
}
#RequestMapping(value ="home", method = RequestMethod.GET)
public ModelAndView viewHome(){
ModelAndView mav=new ModelAndView();
mav.setViewName("home");
return mav;
}
#RequestMapping(value ="java", method = RequestMethod.GET)
public ModelAndView viewJava(){
ModelAndView mav=new ModelAndView();
mav.setViewName("java");
return mav;
}
myjsp.jsp
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title> <tiles:getAsString name="title" ignore="true"></tiles:getAsString >
</title>
<!-- <script type="text/javascript" src="resources/script/js/appjs.js"></script>
--><link rel="stylesheet" type="text/css" href="resources/script/style.css">
</head>
<body>
folder structure
-springwithtiles
---webapp
-----resources
-------images
----------one.jpg
-------script
------------style.css
------------myjs.js
-----web-inf
--------jsp

Resources