-1

I am working on updating our legacy code with uses jsp and servelts to angular 7. However, there are some parts of the legacy code that i still have to maintain. So i have to make some calls to webservices that have below webservice.

@RequestMapping(value = "/mainpage", method = { RequestMethod.GET, RequestMethod.POST })
    public ModelAndView portalMainPage(HttpServletRequest request, HttpServletResponse response) throws Exception { 
/* Code here to do a few things */
return new ModelAndView(".company.portal.mainpage");
}

I try to call this from angular but as you can see it returns a model and view and has its own jsp page for rendering.

How do i call this from angular and have it render the jsp page?

I tried to call it but i get a HTTP 302 error message and it redirects to index.html page which the the welcome page for angular. It is not able to render jsp pages.

The way i call this is directly from the browser: https://company/portal/mainpage.do. After i do this i checked network settings in developer tools. It shows 302 message and then reidrects it to index.html.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Rohan
  • 1
  • 1
  • 4

1 Answers1

0

So i was able to resolve the issue. The problem was not having a view resolver in the xml file.

So i added below code in the xml file. After adding that, the issue was resolved

<mvc:annotation-driven />
<mvc:default-servlet-handler/>
<bean id="viewResolver"
    class="org.springframework.web.servlet.view.UrlBasedViewResolver">
    <property name="viewClass">
        <value>org.springframework.web.servlet.view.tiles2.TilesView</value>
    </property>
</bean>
<bean id="tilesConfigurer"
    class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
    <property name="definitions">
        <list>
            <value>/WEB-INF/config/spring-tiles.xml</value>
            <!-- <value>/WEB-INF/config/cwf/tiles-defs-cwf.xml</value> -->
        </list>
    </property>
</bean>
Rohan
  • 1
  • 1
  • 4