【发布时间】:2014-10-28 09:48:07
【问题描述】:
我在 Spring MVC 控制器中遇到了一个奇怪的问题。
我的 webapp 文件夹中有四个页面
@Controller
public class WelcomeController {
@RequestMapping(value="/wodi/welcome",method=RequestMethod.GET)
public String welcome(){
return "redirect:/pages/webwelcome.html";
}
}
刚才,找到页面http://localhost:8080/pages/webwelcome.html很好,但是现在我有浏览器说的错误:
There was an unexpected error (type=Method Not Allowed, status=405).
Request method 'GET' not supported
我不知道我做了什么影响了它。
我读过WARN : org.springframework.web.servlet.PageNotFound - Request method 'GET' not supported
但这与我的情况不同,因为我使用的是“GET”方法。
下面是我用来启动 Spring 应用程序的 Application.java
@Configuration
@EnableAutoConfiguration
@ComponentScan({"hello","wodinow.weixin.jaskey"})
public class Application {
public static void main(String[] args) {
ApplicationContext ctx = SpringApplication.run(Application.class, args);
System.out.println("Let's inspect the beans provided by Spring Boot:");
String[] beanNames = ctx.getBeanDefinitionNames();
Arrays.sort(beanNames);
for (String beanName : beanNames) {
System.out.println(beanName);
}
}
@Bean
public CommandService commandService(){
return CommandService.getInstance();
}
}
【问题讨论】:
-
发布配置文件web.xml和spring context.xml文件代码。
-
@JavaDev,我没有用那个,我用Spring Boot和Application.java来运行程序。
-
在什么请求下您会收到错误消息:
http://localhost:8080/pages/webwelcome.html或http://localhost:8080//wodi/welcome?看起来你正在使用 eclipse,你清理然后重建项目了吗? -
@SergeBallesta 这两个 URL 都有相同的错误,我尝试清理项目,但仍然相同
标签: java spring spring-mvc