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

关于struts2 超链接传参的问题
strut.xml 中的配置
  <?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="GBK"/>
  <package name="struts2Demo" extends="struts-default">
  <action name="save" class="struts2.saveAction">
  <result name="list" type="chain">list</result>
  </action>
  <action name="delete" class="struts2.deleteAction">
  <result name="list" type="chain">list</result>
  </action>
  <action name="list" class="struts2.listAction">
  <result name="show">/list.jsp</result>
  </action>
  </package>
  </struts>
------------------------------
deleteAction 类

package struts2;

import manager.managerPO;

public class deleteAction {
managerPO manager = new managerPO();
private Integer id;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String execute(){
//System.out.println("id"+id);
//manager.delete(manager.queryById(new Integer(Integer.parseInt(id))));
//manager.delete(manager.queryById(id));
return "list";
}
}
---------------
查询页面
<%@ page language="java" import="java.util.*" pageEncoding="GB18030"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page isELIgnored="false" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
  <base href="<%=basePath%>">
   
  <title>查询页面</title>
   
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">  
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->

  </head>
  
  <body>
  <center>
  <h2>查询页面</h2><hr>
  <table border="1">
  <tr>
  <td>姓名</td>
  <td>性别</td>
  <td>班级</td>
  <td>爱好</td>
  <td>操作</td>
  </tr>
  <c:forEach items="${voes}" var="vo">
  <tr>
  <td>${vo.name }</td>
  <td>${vo.sex}</td>
  <td>${vo.classId}</td>
  <td>${vo.hobby }</td>
  <td>
  <a href="<%=path %>/modify.action&&id=${vo.id}">修改</a>