毕业论文开发语言企业开发JAVA技术.NET技术WEB开发Linux/Unix数据库技术Windows平台移动平台嵌入式论文范文英语论文
您现在的位置: 毕业论文 >> java技术 >> 正文

The requested resource (There is no Action mapped for namespace / and action nam

更新时间:2012-6-6:  来源:毕业论文

package com.xxx.servise;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import com.xxx.basedao.Common;
import com.xxx.model.EmployeeInfo;

public class EmployeeServise {


    public void add(EmployeeInfo e) {
         Connection con = Common.getcon();
        String sql = "insert into info values(?,?)";
        PreparedStatement pstmt = Common.prepare(con, sql);
        try {
            pstmt.setString(1, e.getName());
            pstmt.setString(2, e.getDescription());
            pstmt.executeUpdate();
        } catch (SQLException e1) {
            e1.printStackTrace();
        } finally {
            Common.close(con, pstmt);
        }
    }

Java code
package com.xxx.action;

import java.util.List;

import com.opensymphony.xwork2.ActionSupport;
import com.xxx.model.EmployeeInfo;
import com.xxx.servise.EmployeeServise;

public class EmployeeAction extends ActionSupport {

    private List<EmployeeInfo> employees;
    private EmployeeServise employeeServise = new EmployeeServise();
    private EmployeeInfo employee;
    private int id;

   
   
    public String list() {
        employees = employeeServise.list();
        return "list";
    }

    public String add() {
        employeeServise.add(employee);
        return "add";
    }


HTML code
<%@ page language="java" contentType="text/html; charset=GBK"
    pageEncoding="GBK" import="java.util.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<form action="EmployeeAction!add.action" method="post">
name: <input name="employee.name" id="employee.name">
description:<textarea rows="4" cols="10" name="employee.description" id="employee.description"></textarea>
<input type="submit" value="add">
</form>
</body>
</html>

 


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.enable.DynamicMethodInvocation" value="false" />
    <constant name="struts.devMode" value="false" />

    <package name="Employee" namespace="/" extends="struts-default">


        <action name="EmployeeAction" class="com.xxx.action.EmployeeAction" >
        <result name="add">/Employee-add.jsp</result>
        </action>
    </package>


    <!-- Add packages here -->

</struts>

<action name="EmployeeAction" class="com.xxx.action.EmployeeAction" >
照你这种配置 没有add.action 这个配置 
应该是STRUTS2 的配置吧~~~
EmployeeAction 是不是少了个 /EmployeeAction

设为首页 | 联系站长 | 友情链接 | 网站地图 |

copyright©youerw.com 优尔论文网 严禁转载
如果本毕业论文网损害了您的利益或者侵犯了您的权利,请及时联系,我们一定会及时改正。