Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error:The type javax.portlet.PortletContext cannot be resolved

I am new to spring frame. I am trying to setup the project by downloading the spring framework-4.1.6.and Tomcat-7 however I am getting the below error, even tough I have added the portal-impl-6.1.0.jar file in the build path.

Please let me know how to resolve this.

Error :[The type javax.portlet.PortletContext cannot be resolved. It is indirectly referenced from required .class files]

package com.gontuseries.hellocontroller;


import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.portlet.ModelAndView;
import org.springframework.web.portlet.mvc.AbstractController;

public class HelloController extends AbstractController {

@Override

protected ModelAndView handleRequestInternal(HttpServletRequest request,HttpServletResponse response) throws Exception
    {

 ModelAndView modelandview = new ModelAndView("HelloPage");
  modelandview.addObject("welcomeMessage","Hi User, welcome to the first           spring MVC Application");

  return modelandview;

    }

}

Thanks for your help. Regards, Sumit

like image 348
Sumrock74 Avatar asked Dec 15 '22 15:12

Sumrock74


2 Answers

Change these two lines:

import org.springframework.web.portlet.ModelAndView;
import org.springframework.web.portlet.mvc.AbstractController;

to this:

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;

Notice that I changed "portlet" to "servlet".

like image 120
user2121620 Avatar answered Dec 17 '22 05:12

user2121620


Following lines will resolve the problem:

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractController;
like image 45
Nilesh Swami Avatar answered Dec 17 '22 04:12

Nilesh Swami