为什么这个表单提交之后到不了controller层,是不是action的问题 ,我尝试了好多种action的写法都是报404。。。代码比较乱恳请大佬帮忙看一下
这是前端的form表单的代码
<form action="${pageContext.request.contextPath}/imageRecognition/adgct/adg" method="post" id="formimg" name="img" >
<div class="col-md-1"></div>
<div class="input-group col-md-9">
<input name="imgName" value="${keyword }" class="form-control input-lg" placeholder="请将图片放入指定文件,并输入图片名字" type="text" id="imgName">
<span class="input-group-btn"><button class="btn btn-primary input-lg" type="submit"><strong><span class="glyphicon glyphicon-search" ></span> 识别</strong></button></span>
</div>
</form>
这个是controller的代码
@RequestMapping("/imageRecognition/adgct")
@Controller
public class adgController {
@RequestMapping(value="/adg",method=RequestMethod.POST)
public ModelAndView adg(Img img) {
ModelAndView mv = new ModelAndView();
String imgName = img.getImgName();
System.out.println(imgName);
AdvancedGeneral adv = new AdvancedGeneral();
String kwd = adv.advancedGeneral(imgName);
mv.setViewName("home/search");
mv.addObject("k", kwd);
mv.addObject("keyword", kwd);
return mv;
}
}