1、jsp调用action 不用<form action="">这种方式。还有别的吗?想做个按钮onclick事件直接调用action中我想用的方法。比如返回,菜单的按钮。一般jsp网站如何设计按钮,跳转等?
2、<% 
String path = request.getContextPath(); 
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>这个获得了basePath,怎么放入标签里。先谢谢各位。jspaction

解决方案 »

  1.   

    1.<button onclick=“jsfunciont(调用action)”.....>
    2.value=<%=basePath %>
      

  2.   

    1.button.submit……
    2.<%=basePath%>
      

  3.   

    1 jsp中访问action还是action中的方法?
       ./xxx.do?id=xx根据id的值调用不同的方法可以不?
    2 用<%= %>不行么?
      

  4.   

    可以用ajax 啊,
    button onclick=""; 调用javascript
      

  5.   

    1、用<%=%>
    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>
      

  6.   

    如果有basePath ,那jsp默认路径前都自动加的。
    你可以搞个onclick事件,用脚本做
    function(){
        location.href="action";
    }
      

  7.   

    可以用jquery 使用ajax方式动态访问action
      

  8.   

    1.location.href="xxxx.do!save",不过现在不提倡这么访问xxxxAction中的save()方法了。
    2.如果你用相对路径,那么默认是加在你写的路径前面的,<%=basePath%>可以得到
      

  9.   

    jsp:
    <input type='button' class='submit' value='提交'/>
    js:
    $('document').ready(function() {
        $('.submit').click(function() {
           $.post('text.action',{},function(data){
           alert(data); 
    })
    });
    });
      

  10.   

    onclick用JS写。
    contextPath,取和显示直接用EL表达式。${page.request.contextpath}.
    这些你学完JAVA WEB部分自然就会了,不着急。