java - 如何进行基于注解的RequestMapping

标签 java spring spring-mvc

我正在从ajax调用spring Controller ,例如/test/new.ui。如何在 Controller 方法中进行RequestMapping。

提前致谢。

问候, 拉朱

最佳答案

@Controller
@RequestMapping("/test/") //This is optional to separate the /test/ part from the new.ui if you want to do other urls under the /test/
public class SomeController {

    @RequestMapping("new.ui")  //You can also do the entire url fragment here "/test/new.ui"
    public Object handleNewMethod(/* ModelAttributes, Errors, RequestParams here */) {
        // Code here
    }
}

关于java - 如何进行基于注解的RequestMapping,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4742246/

相关文章:

java - 在公共(public)方法中拦截私有(private)方法返回的对象

java - 通过webapp运行ProcessBuilder的一些问题

java - 带有返回类型和输入参数的Execute方法

java - 使用 IntelliJ REST 客户端测试 Spring MVC POST 会导致 415

Java string.split( ) 在逗号或行尾

java - Jersey 异常 : A message body reader for Java class and MIME media type application/x-www-form-urlencoded was not found

java - 如何从 org.springframework.test.web.servlet.ResultActions 中提取显式内容

java - org.springframework.web.context.ContextLoaderListener(java.lang.ClassNotFoundException)

java - 为什么 Math.pow(long, (1/3)) 总是返回 1?

java - 如何使用 Maven 在 jar 子文件夹中创建具有依赖项的可执行 jar?