1

I am pretty new to Tridion so my question may be basic but I have not found an answer yet. I have a Tridion based Spring MVC project which is working fine and fetching content from SDL Tridion .

Now I am adding a new Controller class which should display a page which has a form and upon submission page should submit the data to another Java method. Just like any other normal Spring MVC application.

But the Tridion project doesn't like that. Do we need to anything special to register our mapping, is it supported in Spring MVC project of Tridion.

Here is my Controller Class

 @Controller
public class UserFormController {
    @RequestMapping(value = "/example/user", method = RequestMethod.GET)
    public ModelAndView showForm() {
        System.out.println("#############Hellooo I was here#################");
        return new ModelAndView("user", "user", new UserForm());
    }
    @RequestMapping(value = "/user", method = RequestMethod.GET)
    public ModelAndView showFormUser() {
        System.out.println("#############Hellooo I was here too#################");
        return new ModelAndView("user", "user", new UserForm());
    }

    @RequestMapping(value = "/example/addUser", method = RequestMethod.POST)
    public String submit(@ModelAttribute("user")UserForm user, 
      BindingResult result, ModelMap model) {
        if (result.hasErrors()) {
            return "error";
        }
        model.addAttribute("name", user.getFirstName());
        model.addAttribute("email", user.getEmail());
        return "userView";
    }
}

This is what I see my Logs

  16:11:17.029 [localhost-startStop-1] INFO  o.s.b.f.s.DefaultListableBeanFactory - Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@ed7f8bf: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,springInitializer,org.springframework.context.annotation.ConfigurationClassPostProcessor.importAwareProcessor,adminController,adminService,productModuleInitializer,defaultDataFormatter,ignoreByNameInRequestFilter,xpmAwareJsonFilter,entityController,listController,navigationController,pageController,regionController,siteMapXmlController,applicationContextHolder,contextEngineImpl,deviceFamiliesEvaluator,defaultMediaHelper.DefaultResponsiveMediaUrlBuilder,defaultMediaHelper.MediaHelperFactoryImpl,defaultMediaHelper,defaultRegionBuilder,defaultViewResolver,csrfConfiguration,localizationFactoryImpl,semanticMapperImpl,semanticMappingRegistryImpl,markupDecoratorRegistryImpl,markupImpl,pluggableMarkupRegistryImpl,viewModelRegistryImpl,springConfiguration,threadLocalManagerImpl,scopedTarget.webRequestContextImpl,webRequestContextImpl,tridionSpringConfig,defaultConditionalEntityEvaluator,componentLinkFieldConverter,dateFieldConverter,embeddedFieldConverter,externalLinkFieldConverter,keywordFieldConverter,multiLineTextFieldConverter,multimediaFieldConverter,numberFieldConverter,textFieldConverter,xhtmlFieldConverter,fieldConverterRegistry,defaultRichTextProcessor,entityBuilderImpl,modelBuilderPipelineImpl,pageBuilderImpl,staticNavigationProvider,xpmMarkupInitializer,xpmRegionConfigImpl,xpmRegionImpl,dd4tUtilsImpl,brokerComponentPresentationProvider,contextServiceClaimsProvider,tridionLinkResolver,defaultContentProvider,springContextConfiguration,tridionLocalizationResolver,dxaSpringInitialization,csrfInterceptor,org.springframework.web.servlet.config.annotation.DelegatingWebMvcConfiguration,requestMappingHandlerMapping,viewControllerHandlerMapping,beanNameHandlerMapping,resourceHandlerMapping,defaultServletHandlerMapping,requestMappingHandlerAdapter,mvcConversionService,mvcValidator,httpRequestHandlerAdapter,simpleControllerHandlerAdapter,handlerExceptionResolver,getStringHttpMessageConverter,staticContentInterceptor,threadLocalInterceptor,mappingJackson2HttpMessageConverter,cacheProvider,taxonomyFactory,pageFactory,linkResolver,richTextWithLinksResolver,serializer,serializerFactory,modelConverter,dataBinder,dcpDataBinderWrapper,databindFactory,webTaxonomyFactory,taxonomyRelationManager,linkProvider,pageProvider,taxonomyProvider,componentPresentationFactory,componentPresentationProvider,dynamicMetaRetriever,binaryContentRetriever,dynamicMappingsRetriever,placeholderConfigurer,fallbackViewResolver,dxaViewResolver,beanNameViewResolver,rssFeedView,atomFeedView,jsonFeedView,objectMapper,jsonFilterProvider,dxaViewModelJsonChainFilter,viewResolver]; root of factory hierarchy
16:11:25.849 [localhost-startStop-1] INFO  o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/admin/refresh || /*/admin/refresh],methods=[GET],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String com.sdl.dxa.dxawebapp.controller.AdminController.handleRefresh()
16:11:25.856 [localhost-startStop-1] INFO  o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/system/mvc/Framework/Entity/Entity/{entityId}],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String com.sdl.webapp.common.controller.EntityController.handleGetEntity(javax.servlet.http.HttpServletRequest,java.lang.String) throws java.lang.Exception
16:11:25.856 [localhost-startStop-1] INFO  o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/system/mvc/Framework/Entity/system/mvc/Shared/Error/SectionError],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String com.sdl.webapp.common.controller.BaseController.handleJspIncludesErrors()
16:11:25.859 [localhost-startStop-1] INFO  o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/system/mvc/Framework/List/List/{entityId}],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String com.sdl.webapp.common.controller.ListController.handleGetList(javax.servlet.http.HttpServletRequest,java.lang.String) throws java.lang.Exception
16:11:25.859 [localhost-startStop-1] INFO  o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/system/mvc/Framework/List/Entity/{entityId}],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String com.sdl.webapp.common.controller.EntityController.handleGetEntity(javax.servlet.http.HttpServletRequest,java.lang.String) throws java.lang.Exception
16:11:25.860 [localhost-startStop-1] INFO  o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/system/mvc/Framework/List/system/mvc/Shared/Error/SectionError],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String com.sdl.webapp.common.controller.BaseController.handleJspIncludesErrors()
16:11:25.864 [localhost-startStop-1] INFO  o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/system/mvc/Framework/Navigation/Navigation/{entityId}],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String com.sdl.webapp.common.controller.NavigationController.handleGetNavigation(javax.servlet.http.HttpServletRequest,java.lang.String,java.lang.String) throws java.lang.Exception
16:11:25.865 [localhost-startStop-1] INFO  o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/system/mvc/Framework/Navigation/SiteMap/{entityId}],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String com.sdl.webapp.common.controller.NavigationController.handleGetSiteMap(javax.servlet.http.HttpServletRequest,java.lang.String) throws com.sdl.webapp.common.api.navigation.NavigationProviderException
16:11:25.867 [localhost-startStop-1] INFO  o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/system/mvc/Framework/Navigation/system/mvc/Shared/Error/SectionError],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String com.sdl.webapp.common.controller.BaseController.handleJspIncludesErrors()
16:11:25.888 [localhost-startStop-1] INFO  o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/**],methods=[],params=[],headers=[],consumes=[],produces=[text/html || */*],custom=[]}" onto public java.lang.String com.sdl.webapp.common.controller.PageController.handleGetPage(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) throws java.lang.Exception
16:11:25.889 [localhost-startStop-1] INFO  o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/**],methods=[],params=[format],headers=[],consumes=[],produces=[application/rss+xml || application/json || application/atom+xml],custom=[]}" onto public org.springframework.web.servlet.ModelAndView com.sdl.webapp.common.controller.PageController.handleGetPageFormatted(javax.servlet.http.HttpServletRequest)
16:11:25.891 [localhost-startStop-1] INFO  o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/resolve/{itemId}],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String com.sdl.webapp.common.controller.PageController.handleResolve(java.lang.String,java.lang.String,java.lang.String,java.lang.String) throws com.sdl.webapp.common.exceptions.DxaException
16:11:25.892 [localhost-startStop-1] INFO  o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/{locPath}/resolve/{itemId}],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String com.sdl.webapp.common.controller.PageController.handleResolveLoc(java.lang.String,java.lang.String,java.lang.String,java.lang.String) throws com.sdl.webapp.common.exceptions.DxaException
16:11:25.892 [localhost-startStop-1] INFO  o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/se_blank.html],methods=[],params=[],headers=[],consumes=[],produces=[text/html],custom=[]}" onto public java.lang.String com.sdl.webapp.common.controller.PageController.blankPage()
16:11:25.893 [localhost-startStop-1] INFO  o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/navigation.json],methods=[],params=[],headers=[],consumes=[],produces=[application/json],custom=[]}" onto public com.sdl.webapp.common.api.model.entity.SitemapItem com.sdl.webapp.common.controller.PageController.handleGetNavigationJson(javax.servlet.http.HttpServletRequest) throws com.sdl.webapp.common.api.navigation.NavigationProviderException,com.fasterxml.jackson.core.JsonProcessingException
16:11:25.894 [localhost-startStop-1] INFO  o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/system/mvc/**],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public void com.sdl.webapp.common.controller.PageController.handleGetUnknownAction(javax.servlet.http.HttpServletRequest)
16:11:25.897 [localhost-startStop-1] INFO  o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/system/mvc/Shared/Error/SectionError],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String com.sdl.webapp.common.controller.BaseController.handleJspIncludesErrors()
16:11:25.900 [localhost-startStop-1] INFO  o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/system/mvc/Framework/Region/Region/{regionName}],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String com.sdl.webapp.common.controller.RegionController.handleGetRegion(javax.servlet.http.HttpServletRequest,java.lang.String) throws java.lang.Exception
16:11:25.901 [localhost-startStop-1] INFO  o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/system/mvc/Framework/Region/system/mvc/Shared/Error/SectionError],methods=[],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public java.lang.String com.sdl.webapp.common.controller.BaseController.handleJspIncludesErrors()
16:11:25.903 [localhost-startStop-1] INFO  o.s.w.s.m.m.a.RequestMappingHandlerMapping - Mapped "{[/sitemap.xml],methods=[],params=[],headers=[],consumes=[],produces=[application/xml],custom=[]}" onto public java.lang.String com.sdl.webapp.common.controller.SiteMapXmlController.handleGetSiteMapXml(javax.servlet.http.HttpServletResponse) throws com.sdl.webapp.common.api.navigation.NavigationProviderException
16:11:26.432 [localhost-startStop-1] INFO  o.s.w.s.h.SimpleUrlHandlerMapping - Mapped URL path [/resources/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
16:11:26.755 [localhost-startStop-1] INFO  o.d.d.builder.json.JsonDataBinder - Creating a JsonDataBinder instance.
16:11:26.784 [localhost-startStop-1] WARN  o.d.databind.builder.BaseDataBinder - Setting meta key to default: viewName
16:11:2

There is no mapping to /user or /example/user. Can somebody please explain what needs to be done differently for Tridion application ? Is there any tutorial for this..Any help is appreciated

2

It seems you use dd4t 2. In the dispatcher-servlet.xml file you need to add your controller:

<!-- Configure me: change this to the base-package 
     where your overridden controllers are -->
<context:component-scan 
  base-package="org.dd4t.test.web.controller,my.base.package"
  annotation-config="true"/>

For my.base.package use the base namespace your UserFormController is in.

  • Yeah , Thanks it worked I have the following question @Bean public InternalResourceViewResolver viewResolver() { InternalResourceViewResolver viewResolver = new InternalResourceViewResolver(); viewResolver.setViewClass(JstlView.class); viewResolver.setPrefix("/WEB-INF/Views/jsp/"); viewResolver.setSuffix(".jsp"); return viewResolver; } I am getting this message message /WEB-INF/Views/user.jsp The requested resource is not available. Though I do have a user.jsp on that path. – Abhishek Galoda Jun 12 '17 at 8:28
  • For the prefix you indicate "/WEB-INF/Views/jsp/", The page should be in "/WEB-INF/Views/jsp/user.jsp" – Raúl Escudero Jun 12 '17 at 9:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.