spring mvc 中 controller 路径配置


下图中,由于红色部分(value="/")的存在,导致 host:port/项目/dimlist 无法被映射到dimList方法,解决办法是将其去掉。

package cn.bgodata.x.zero.web.ctrl;

import org.springframework.stereotype.Component;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

@Component
@RequestMapping("/dimlist")
public class ZeroBiController {

    @RequestMapping(value="/", method=RequestMethod.GET)
    public String dimList(Model model) {
        
        return "dimlist";
    }
    
    @RequestMapping(value="/{randomcode}/nani", method=RequestMethod.POST)
    public String dimList(Model model, String randomcode) {
        System.out.println("randomcode = " + randomcode);
        return "nani";
    }
}

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM