hahalzb
hahalzb
2008-11-17 20:58

使用PropertiesMethodNameResolver提示找不到路径

已采纳

我的工程名叫plagiarism
我的jsp目录结构为:
[quote]
WebRoot
-jsp
-login
-login.jsp
-success.jsp
[/quote]

login.jsp为:
[code="html"]


align="center" bgColor="#8199c5" border="0">
                                                                        <tbody>

                                                                            <tr>
                                                                                <td
                                                                                    background="/imc/images/login/login_tablebg.jpg"
                                                                                    height="20">
                                                                                    &nbsp;
                                                                                    <span class="cmn_normalBoldFont">登录</span>
                                                                                </td>                                                                               </tr>                                                                               <tr>                                                                                    <td bgColor="#ffffff" height="100" align="center">
                                                                                    <table cellSpacing="5" cellPadding="0"
                                                                                        width="100%" border="0">
                                                                                        <tbody align="left">                                                                                                <tr>                                                                                                    <td>
                                                                                                    <table border="0" cellpadding="5"
                                                                                                        cellspacing="0" width="100%">
                                                                                                        <tbody>                                                                                                             <tr>                                                                                                                    <td width="24%" class="cmn_wdper_30">
                                                                                                                    <label id="_idJsp10"
                                                                                                                        class="cmn_normalFont">
                                                                                                                        用户
                                                                                                                    </label>
                                                                                                                </td>
                                                                                                                <td width="76%" class="cmn_wdper_70">
                                                                                                                    <input id="loginName" name="loginName"
                                                                                                                        type="text" value="" maxlength="32"
                                                                                                                        style="FONT-SIZE: 10pt; WIDTH: 150px; FONT-FAMILY: Arial, '宋体';" />
                                                                                                                </td>
                                                                                                            </tr>
                                                                                                            <tr>
                                                                                                                <td class="cmn_wdper_30"></td>
                                                                                                                <td class="cmn_wdper_70"></td>
                                                                                                            </tr>
                                                                                                            <tr>
                                                                                                                <td align="left" class="cmn_wdper_30">
                                                                                                                    <label id="_idJsp15"
                                                                                                                        class="cmn_normalFont">
                                                                                                                        密码
                                                                                                                    </label>
                                                                                                                </td>
                                                                                                                <td class="cmn_wdper_70">
                                                                                                                    <input type="password" id="password"
                                                                                                                        name="password" value="" maxlength="32"
                                                                                                                        style="FONT-SIZE: 10pt; WIDTH: 150px; FONT-FAMILY: Arial, '宋体';" />
                                                                                                                </td>
                                                                                                            </tr>
                                                                                                            <tr>
                                                                                                                <td class="cmn_wdper_30"></td>
                                                                                                                <td class="cmn_wdper_70"></td>
                                                                                                            </tr>
                                                                                                            <tr>
                                                                                                                <td align="left" class="cmn_wdper_30">
                                                                                                                    <label id="_idJsp15"
                                                                                                                        class="cmn_normalFont">
                                                                                                                        校验码
                                                                                                                    </label>
                                                                                                                </td>
                                                                                                                <td class="cmn_wdper_70">
                                                                                                                    <input type="text" id="validStr"
                                                                                                                        name="validateCode" value=""
                                                                                                                        maxlength="32"
                                                                                                                        style="FONT-SIZE: 10pt; WIDTH: 150px; FONT-FAMILY: Arial, '宋体';" />
                                                                                                                    <img src="../../validateCodeServlet" width="60"
                                                                                                                        height="20" border="0">
                                                                                                                </td>
                                                                                                            </tr>
                                                                                                            <tr>
                                                                                                                <td class="cmn_wdper_30"></td>
                                                                                                                <td class="cmn_wdper_70"></td>
                                                                                                            </tr>
                                                                                                            <tr>
                                                                                                                <td align="left" class="cmn_wdper_30">
                                                                                                                    <label id="_idJsp15"
                                                                                                                        class="cmn_normalFont">
                                                                                                                        类型
                                                                                                                    </label>
                                                                                                                </td>
                                                                                                                <td class="cmn_wdper_70">
                                                                                                                    <span class="boldSize12Font"> <select
                                                                                                                            name="select2" class="ctrl_selectShort"
                                                                                                                            style="FONT-SIZE: 10pt; WIDTH: 150px; FONT-FAMILY: Arial, '宋体';">
                                                                                                                            <option selected="selected" id="student">
                                                                                                                                学生
                                                                                                                            </option>
                                                                                                                            <option id="admin">
                                                                                                                                管理员
                                                                                                                            </option>
                                                                                                                            <option id="teacher">
                                                                                                                                教师
                                                                                                                            </option>
                                                                                                                        </select> </span>
                                                                                                                </td>
                                                                                                            </tr>
                                                                                                            <tr>
                                                                                                                <td class="cmn_wdper_30"></td>
                                                                                                                <td class="cmn_wdper_70"></td>
                                                                                                            </tr>

                                                                                                            <tr>
                                                                                                                <td class="cmn_wdper_30"></td>
                                                                                                                <td class="cmn_wdper_70">

                                                                                                                    <input type="submit" value="登录"
                                                                                                                        class="ctrl_btnShort" />
                                                                                                                    &nbsp;&nbsp;&nbsp;
                                                                                                                </td>
                                                                                                            </tr>
                                                                                                        </tbody>
                                                                                                    </table>
                                                                                                [/code]

Spring配置文件为:
[code="xml"]<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd" >

<bean id="urlMapping"
    class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
    <property name="mappings">
        <props>
            <prop key="/*login.do">loginController</prop>
            <prop key="/*Admin.do">adminController</prop>
        </props>
    </property>
</bean>
<!-- 根据Admin前缀决定调用controller的哪个方法 -->
<bean id="propMethodResolver"
    class="org.springframework.web.servlet.mvc.multiaction.PropertiesMethodNameResolver">
    <property name="mappings">
        <props>
            <prop key="/firstlogin.do">login</prop>
        </props>
    </property>
</bean>

<bean id="loginController"
    class="com.bupt.plagiarism.web.login.LoginController">
    <property name="methodNameResolver" ref="propMethodResolver" />
    <property name="success" value="success" />

</bean>
<bean id="adminController"
    class="com.bupt.plagiarism.web.admin.AdminController">
    <property name="userDao" ref="userDao" />
    <property name="methodNameResolver" ref="propMethodResolver" />
    <property name="addSuccess" value="addSuccess" />
</bean>
<!-- 视图解析 -->
<bean id="viewResolver"
    class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <!--  <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/> -->
    <property name="prefix" value="/jsp/login/" />
    <property name="suffix" value=".jsp" />
</bean>

[/code]
当我打开login.jsp页面输入信息提交时,浏览器里的URL为:
[quote]http://localhost:8090/plagiarism/jsp/login/firstlogin.do[/quote]
但页面确实:
[quote]HTTP Status 404 -


type Status report

message

description The requested resource () is not available.

[/quote]
我觉得是页面action和配置文件里路径哪里不匹配造成的,但弄了一下午,也没找到地方。
所以来请大家帮忙。
谢谢了~~~

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

1条回答

  • bohemia bohemia 13年前

    1.WEB.xml配置好了么?

    [code="java"]
    sample

    org.springframework.web.servlet.DispatcherServlet

    1


    sample
    /*
    [/code]

    2.
    [code="java"] loginController [/code]修改成:
    [code="java"] loginController [/code]
    试试看.

    点赞 评论 复制链接分享

相关推荐