1在HeadFirstStruts2chapter02-05中,直接修改struts.xml文件,去掉method属性和通配符属性
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="true"/>
<package name="manage" namespace="/" extends="struts-default">
<action name="student" class="com.cruise.action.StudentAction" >
<result name="success">success.jspresult>
action>
<action name="grade" class="com.cruise.action.GradeAction" >
<result name="success">success.jspresult>
action>
package>
struts>
2index.jsp中增加增加测试代码,在调用路径上确定所要调用的方法,
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
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 heretitle>
head>
<body>
<h1>动态方法调用h1>
<a href="student!list" target="_blank">学生信息查询a>
<a href="student!add" target="_blank">学生信息添加a>
<a href="student!update" target="_blank">学生信息修改a>
<a href="student!delete" target="_blank">学生信息删除a>
<br/><br/>
<a href="grade!list" target="_blank">班级信息查询a>
<a href="grade!add" target="_blank">班级信息添加a>
<a href="grade!update" target="_blank">班级信息修改a>
<a href="grade!delete" target="_blank">班级信息删除a> <br/>
body>
html>
3测试
http://localhost:8080/HeadFirstStruts2chapter02_05/
第12讲 struts2动态方法调用
最新推荐文章于 2019-06-26 22:58:00 发布