日期:2014-05-20  浏览次数:20796 次

spring mvc404问题
spring版本为3.0.6,准备试用一下。但是照着demo自己稿了一个却出现了404,找了1个多小时没找到原因,求解。
web.xml代码:
XML code
<servlet>
        <servlet-name>spring</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
        <servlet-name>spring</servlet-name>
        <url-pattern>*.do</url-pattern>
    </servlet-mapping>

controller代码:
Java code

@Controller
public class RuleController {
    private Log log = LogFactory.getLog(RuleController.class);

    /**
     * 
     * @param model
     * @param request
     * @param response
     * @return
     * 
     */
    @RequestMapping(value = "/login.do", method = RequestMethod.POST)
    public ModelAndView logon(HttpServletRequest request, HttpServletResponse response, User user) {
        ModelAndView model = new ModelAndView("hello");
        model.addObject("pwd", user.getPassWord());
        log.info("log in!");
        return model;
    }
}



applicationContext.xml中只配置了如下bean
XML code
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix" value="/WEB-INF/pages/" />
        <property name="suffix" value=".jsp" />
    </bean>


访问 http://localhost:8080/springmvc/login.do,出现404,日志如下:
No mapping found for HTTP request with URI [/springmvc/login.do,] in DispatcherServlet with name 'spring'
大家看看什么原因呢,先谢谢了。

------解决方案--------------------
请问你用的什么服务器启动的呢?TomCat?是不是因为[/springmvc/login.do,]中的/springmvc呢?还有就是中括号里的逗号。
------解决方案--------------------
是不是路径的错误???
还有,,,为什么...访问 http://localhost:8080/springmvc/login.do,
do后的逗号有什么说法???
------解决方案--------------------

xx-servlet.xml配好没?
你看看我这个
http://blog.csdn.net/zuxianghuang/article/details/6525432