丹为自己活得精彩
2016-07-09 10:10SpringMVC一直报404,访问不到请求的action,求各位大神帮帮忙看看
<?xml version="1.0" encoding="UTF-8"?>
SpringMVC2
index.html
index.htm
index.jsp
default.html
default.htm
default.jsp
SpringMVC
org.springframework.web.servlet.DispatcherServlet
contextConfigLocation
classpath*:config/SpringMVC-servlet.xml
1
SpringMVC
/
<?xml version="1.0" encoding="UTF-8"?>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-3.0.xsd">
<bean class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping"/>
<bean class="org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter"/>
<bean name="/test1/multi" class="com.tag.web.controller.MultiController">
<property name="methodNameResolver">
<ref bean="ParamMethodResolver"/>
</property>
</bean>
<bean id="ParamMethodResolver" class="org.springframework.web.servlet.mvc.multiaction.ParameterMethodNameResolver">
<property name="paramName" value="action"></property>
</bean>
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/"></property>
<property name="suffix" value=".jsp"></property>
</bean>
```package com.tag.web.controller;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.multiaction.MultiActionController;
public class MultiController extends MultiActionController{
public ModelAndView Add(HttpServletRequest request,HttpServletResponse response){
System.out.println("=====add======");
return new ModelAndView("/multi","method","add");
}
public ModelAndView update(HttpServletRequest request,HttpServletResponse response){
System.out.println("=====update======");
return new ModelAndView("/multi","method","update");
}
}
访问的时候请求的是这个地址:http://localhost:8080/SpringMVC2/test1/multi?action=add
- 点赞
- 回答
- 收藏
- 复制链接分享
5条回答
为你推荐
- SpringMVC跨服务器上传文件,上传至文件服务器时报404错误
- spring
- java-ee
- intellij-idea
- 5个回答
- 哪位大神帮我解决一下eclipse运行突然报404,好像是spring配置文件有问题
- spring
- tomcat
- eclipse
- jar
- java
- 3个回答
- SpringMVC后台action取不到页面参数
- spring
- 0个回答
- springMVC 拦截器 异步【急】大神在哪里?帮帮忙
- 计算机
- 1个回答
- ssm框架静态文件引入报404,求大神指点
- spring
- 控制台
- 4个回答