日期:2014-05-19  浏览次数:20694 次

sturts的一个小问题 跟帖有分
在做文件上传,对于上传的不是图片类型进行判断,如果不是则重新输入。但是输入页面中有个select是通过一个action从数据库中取得数据的,所以说result 的input在配置时,不应该直接挑转到页面,而是应该跳转到action 但是现在说HTTP Status 404 - There is no Action mapped for namespace / and action name /getClasses.action.如果直接访问时可以的(直接输入action,则跳转到输入页面)。求解释。

struts配置。
XML code
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
    "http://struts.apache.org/dtds/struts-2.0.dtd">
    
<struts>
    <constant name="struts.i18n.encoding" value="UTF-8"/>
    <constant name="struts.custom.i18n.resources" value="globalMessages" />

    <package name="StudentManagement" extends="struts-default" namespace="/">
        <action name="TeacherList" class="com.dcj.action.TeacherManagementAction" method="TeacherList">
            <result name="success">admin/teacherManage.jsp</result>
        </action>
        
        <action name="addTeacher" class="com.dcj.action.TeacherManagementAction" method="addTeacher">
            <result name="success" type="redirectAction">TeacherList</result>
        </action>
        
        <action name="getClasses" class="com.dcj.action.ClassManagementAction" method="getClasses">
            <result name="success">teacher/addStudent.jsp</result>
        </action>
              
        <action name ="addStudent" class ="com.dcj.action.StudentManagementAction" >
            <interceptor-ref name ="fileUpload" >
                <param name="allowedTypes">image/bmp,image/png.image/jpeg,/image/gif</param>
            </interceptor-ref>
            <interceptor-ref name="defaultStack"/>
            <result name ="success" >student/studentInfo.jsp </result >
            <result name ="input" type="chain">getClasses.action</result>
        </action >
        
    </package>
    

</struts>


------解决方案--------------------
探讨
另外,为了防止上传文件重名,imageFileName = new Date().getTime() + getExtention(fileName);
newData。getTime()为什么得到1299303883875这个值。