1、jsp调用action 不用<form action="">这种方式。还有别的吗?想做个按钮onclick事件直接调用action中我想用的方法。比如返回,菜单的按钮。一般jsp网站如何设计按钮,跳转等?
2、<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>这个获得了basePath,怎么放入标签里。先谢谢各位。jspaction
2、<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>这个获得了basePath,怎么放入标签里。先谢谢各位。jspaction
2.value=<%=basePath %>
2.<%=basePath%>
./xxx.do?id=xx根据id的值调用不同的方法可以不?
2 用<%= %>不行么?
button onclick=""; 调用javascript
2、用隐藏表单
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'test.jsp' starting page</title>
<script type="text/javascript">
function showValue() {
document.getElementById("path").value = document.getElementById("hidden").value;
}
</script>
</head>
<body>
BathPath:<input id="path" type="text" value="<%=basePath %>">
<input type = "hidden" name="hidden" value="<%=basePath%>">
<input type="button" value="showValue" onclick="showValue()">
</body>
</html>
你可以搞个onclick事件,用脚本做
function(){
location.href="action";
}
2.如果你用相对路径,那么默认是加在你写的路径前面的,<%=basePath%>可以得到
<input type='button' class='submit' value='提交'/>
js:
$('document').ready(function() {
$('.submit').click(function() {
$.post('text.action',{},function(data){
alert(data);
})
});
});
contextPath,取和显示直接用EL表达式。${page.request.contextpath}.
这些你学完JAVA WEB部分自然就会了,不着急。