I have a simple controller specified below,
@Controller
@RequestMapping("/add/*")
public class RequestMappingController {
@Autowired
private MathOps mathOps;
@RequestMapping(value = "add2Operands", method = RequestMethod.GET)
public String add(@RequestParam("op1") String op1, @RequestParam("op2") String op2, Model model) {
int num1 = Integer.parseInt(op1);
int num2 = Integer.parseInt(op2);
int result = mathOps.add(num1, num2);
model.addAttribute("op1", op1).addAttribute("op2", op2).addAttribute("result", result);
return "adder";
}
}
This is my InteralViewResolver configuration
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="WEB-INF/views/"/>
<property name="suffix" value=".jsp"/>
</bean>
and the adder.jsp file is directly under the /views folder.
When i navigate to
http://localhost:8080/mvc/add/add2Operands?op1=12&op2=2
i get a 404 error
/mvc/add/WEB-INF/views/adder.jsp
where “mvc” is my context path.
What am i doing wrong here?
Thanks
try changing to:
notice the “/” before WEB-INF