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

FreezingCoffin 2011-10-14 09:54:49

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);
}
}




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";
}



<%@ 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 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>

...全文
626 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
nizhicheng 2011-10-26
  • 打赏
  • 举报
回复
应该是STRUTS2 的配置吧~~~
EmployeeAction 是不是少了个 /EmployeeAction
xiongyuanming 2011-10-26
  • 打赏
  • 举报
回复
<action name="EmployeeAction" class="com.xxx.action.EmployeeAction" >
照你这种配置 没有add.action 这个配置

51,408

社区成员

发帖
与我相关
我的任务
社区描述
Java相关技术讨论
javaspring bootspring cloud 技术论坛(原bbs)
社区管理员
  • Java相关社区
  • 小虚竹
  • 谙忆
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧