struts2动态指定问题DMI求帮助
struts.xml配置:<packagename="default"namespace="/"extends="struts-default"><actionname=...
struts.xml配置:
<package name="default" namespace="/" extends="struts-default">
<action name="teacher" class="StrutsDemo03ActionMethod.StrutsDemoTeacher"> <result>/teacher.jsp</result> </action> </package>
StrutsDemoTeacher类:
package StrutsDemo03ActionMethod;
import com.opensymphony.xwork2.ActionSupport;
public class StrutsDemoTeacher extends ActionSupport { public String addTeacher(){ return SUCCESS; }}
index.jsp内容:
<%@ page language="java" import="java.util.*" pageEncoding="gb18030"%><%String path = request.getContextPath(); //获取当前的路径String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%><!-- 获取http ,localhost,端口8080--><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html> <head> <!-- <base href="<%=basePath%>"> --> <title>My JSP 'index.jsp' starting page</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> <a href="<%=path %>/teacher!addTeacher">添加老师信息</a> </body></html> 展开
<package name="default" namespace="/" extends="struts-default">
<action name="teacher" class="StrutsDemo03ActionMethod.StrutsDemoTeacher"> <result>/teacher.jsp</result> </action> </package>
StrutsDemoTeacher类:
package StrutsDemo03ActionMethod;
import com.opensymphony.xwork2.ActionSupport;
public class StrutsDemoTeacher extends ActionSupport { public String addTeacher(){ return SUCCESS; }}
index.jsp内容:
<%@ page language="java" import="java.util.*" pageEncoding="gb18030"%><%String path = request.getContextPath(); //获取当前的路径String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%><!-- 获取http ,localhost,端口8080--><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html> <head> <!-- <base href="<%=basePath%>"> --> <title>My JSP 'index.jsp' starting page</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> <a href="<%=path %>/teacher!addTeacher">添加老师信息</a> </body></html> 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询