I am trying to convert my app written in Spring MVC 2.5 to use the annotated style of controller.
Apparently, I am unable to get things going.
I have a mapping as below:
<li><a href="eqr/eqrItemList.htm"><span>Equipment Qual Report</span></a></li>
I created my controller like below:
@Controller
@RequestMapping("/eqr")
public class EQRMainController {
private SimpleEQRTransManager eqrManager;
protected final Log logger = LogFactory.getLog(getClass());
@RequestMapping(value = "/eqrItemList.htm")
public String setupForm(
@RequestParam(value = "plant", required = false) String plant,
return "eqrmain";
}
}
I wanted to use the relative path so I set my request mapping at the class type level. But apparently, I am getting a 404 not found and a Handler mapping not found error at the tomcat console.
It says:
No mapping found for HTTP request with URI [/myapp/eqr/eqrItemList.htm]
I look at the Firebug console and it is requesting below path:
http://localhost:8080/myapp/eqr/eqrItemList.htm
I don’t know why it can’t find the mapping.
Are you sure you’ve configured the context correctly for annotations?
In the MVC context configuration (typically called
dispatcher-servlet.xml, depending on the name if your servlet) you can configure MVC annotation support quite simply using this element:<mvc:annotation-driven />This is the easiest way to tell Spring that you’re going to use MVC annotations. Here’s a snippet from one of my projects to put it into context:
Careful; this is Spring 3 so it may not fully apply for 2.5. Check the reference documentation (it explains this quite thoroughly).