Announcement Announcement Module
Collapse
No announcement yet.
Excel view cannot find page Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Excel view cannot find page

    Hi,

    I'm migrating my project from Spring 2.0 into Spring 2.5.
    But when I changed to Spring 2.5, my excel view is looking for a jsp page instead of going to AbstractExcelView class.
    It was working perfectly in Spring 2.0. Is there any difference with excel view in Spring 2.5?

    Here's my xxx-servlet.xml snippet
    Code:
    <bean id="viewResolver"
    		class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    		<property name="prefix" value="/WEB-INF/jsp/"/>
    		<property name="suffix" value=".jsp"/>
    	</bean>
    	
    	<bean class="org.springframework.web.servlet.view.ResourceBundleViewResolver">
            <property name="basename" value="views"/>
        </bean>
    
    <bean 	id="excelController" class="com.test.TestExcelController">
    	</bean>
       
        <bean 	id="excelView" class="com.test.view.DataExcelView">
        </bean>
    
    
    	<bean id="simpleUrlMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
    		<property name="mappings">
    			<props>
    				<prop key="/test.htm">excelController</prop>
    			</props>
    		</property>
    	</bean>
    views.properties
    Code:
    excel-view.class=com.test.view.DataExcelView
    Controller, please ignore the "TestDao" I have checked this is ok, but the problem is coming when "return new ModelAndView("excel-view", "model", model);" it supposed to go to the excel-view.class=com.test.view.DataExcelView . It never go to DataExcelView class. Instead it's looking for excel-view.jsp
    Code:
    public class TestExcelController extends AbstractController
    {
    	@Override
    	protected ModelAndView handleRequestInternal(HttpServletRequest req, HttpServletResponse resp) throws Exception
    	{
    (TestDao)getApplicationContext().getBean("testDAO");
    		
    		List<Data> dataList = asrunDao.getResultData();
    
    		Map<String, Object> model = new HashMap<String, Object>();
    		model.put("data", dataList);
    		
    	    return new ModelAndView("excel-view", "model", model);
    	}
    }
    AbstractExcelView
    Code:
    public class DataExcelView extends AbstractExcelView
    {
     @Override
        protected void buildExcelDocument(Map model,  HSSFWorkbook workbook, HttpServletRequest request, HttpServletResponse response)throws Exception
        {
             System.out.println("BUILD EXCEL DOCUMENT");   ---> It doesn't even goes here
           // do something here 
        }
    }
    Can anyone point me where did I do wrong?

  • #2
    Make sure the ResourceBundleViewResolver kicks in BEFORE the InternalResouceViewResolver. Set the order property and make the RBVR lower than the IRVR.

    Also your bean definition for your view isn't doing anything, you can remove that. Saves you some resources.

    Comment


    • #3
      Thanks

      But now I have "Could not open ServletContext resource"

      Comment

      Working...
      X