ajax传值,servlet取值问题

lengjian 发布于 2013/10/28 11:34
阅读 1K+
收藏 0

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
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>成功案例</title>
     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
 <script type="text/javascript" src="<%=basePath%>manager/news/src/bkLib.js"></script>
 <script type="text/javascript" src="<%=basePath%>manager/news/src/nicConfig.js"></script>
 <script type="text/javascript" src="<%=basePath%>manager/news/src/nicEdit.js"></script>
 <script type="text/javascript" src="<%=basePath%>jquery/jquery.min.js"></script>
 <script type="text/javascript">
 function showFile(){
  var jsonStr=window.showModalDialog("<%=basePath%>upload/upload.jsp",null,"dialogWidth=500px;dialogHeight=500px");
  $("#f_id").val(jsonStr);
  loadImg(jsonStr);
 }
 function loadImg(fids){
  $("#imgs").html();
  $.ajax({
   url: "<%=basePath%>/servlet/Uploadify",
   type:"POST",
   data:{'state':'1','fids':fids},
   success:function(a,b,c,d){
    if(a=="")
     return;
    var fileStr=eval('(' + a + ')');
    for(var i=0;i<fileStr.length;i++){
     $("#imgs").html($("#imgs").html()+"<img width=100 height=100 src=<%=basePath%>"+fileStr[i].f_url+">");
    }
   }
  });
 }
 
 function save(){
  $.ajax({
   url: "<%=basePath%>/servlet/StoriesSlt?state=save",
   type:"POST",
   data:{'s_id':$("#s_id").val(),
    's_title':$("#s_title").val(),
    's_explain':$("#s_explain").val(),
    'f_id':$("#f_id").val(),
    'type':$("#type").val(),
    'language':$("#language").val(),
    'content':$("#content").val()
    },
   success:function(a,b,c,d){
    alert("保存成功!");
    window.opener.loadPage('<%=basePath%>/servlet/StoriesSlt?state=list&language=${language_z}');
    window.opener = null;
    window.close();
   }
  });
 }
 
 function loadpage(){
  loadImg("${stories.f_id}");
 }
   bkLib.onDomLoaded(function() {
    nicEditors.allTextAreas()
   });
 </script>
  </head>
 
<!-- 样式 --> 
<style type="text/css">
.ffd{ border:1px solid #999;}
td.ffd { background:#000;}
</style>

  <body  onload="loadpage()" style="background:url(<%=basePath%>images/r_bg.jpg);">
  <c:if test="${language_z==0}">
   <h3>中文案例</h3>
   <input type="hidden" value="0" id="language"/>
  </c:if>
  <c:if test="${language_z==1}">
   <h3>英文案例</h3>
   <input type="hidden" value="1" id="language"/>
  </c:if>
    <table class="ffd"  border="0" cellspacing="1" cellpadding="0" width="750px" height="300px" style=" margin-bottom:30px; font-size:12px; line-height:25px;background:#f1f1f1;">
     <tr>
      <td  style=" width:100px; background:#999; color:#fff;">
     标题
   </td>
      <td style=" background:#dcdcdc; color:#fff; height:30px;padding-left:0px;">
       <input type="hidden" id="s_id" value="${stories.s_id}"/>
       <input type="text" id="s_title"  value="${stories.s_title}"/>
      </td>
     </tr>
     <tr>
      <td style=" background:#999; color:#fff;">说明</td>
      <td style=" background::#dcdcdc; height:50px; padding-left:0px;">
       <!-- <textarea rows="5" cols="70" id="s_explain">${stories.s_explain}</textarea> -->
       <input type="text" id="s_explain"/>
       </td>
     </tr>
     <tr>
    <td style=" background:#999; color:#fff; width:100px;">
     内容
    </td>
    <td>
     <textarea  cols="70" rows="30" id="content"></textarea>
    </td>
   </tr>
     <tr>
      <th style=" background:#999; color:#fff;">类型</th>
      <td style=" background:#dcdcdc; color:#fff; height:30px;padding-left:10px;">
       <select id="type">
        <option value="0" <c:if test="${stories.type==0}">selected="selected"</c:if> >商标</option>
        <option value="1" <c:if test="${stories.type==1}">selected="selected"</c:if>>专利</option>
       </select>
      </td>
     </tr>
     <tr>
      <td style=" background:#999; color:#fff;">案例文件</td>
      <td style=" background:#dcdcdc; color:#fff; height:30px;padding-left:10px;">
       <input type="text"  readonly="readonly"  id="f_id"  value="${stories.f_id}"/>
       <input type="button" value="选择文件" onclick="showFile()"/>
      </td>
     </tr>
     <tr>
      <td colspan="2" height="50px"><div id="imgs"></div></td>
     </tr>
    </table>
    <input value="保存" type="button" onclick="save()">
  </body>
</html>

以上是一些简单页面传值,用的是ajax,textarea标签的值,在servlet里取不到值,请大家帮帮忙,谢谢!

加载中
0
lazyphp
lazyphp

能不能放到 代码插入框去显示呢。

现在看着就蛋疼

0
lengjian
lengjian

忘记了,不过现在已经解决了,谢谢!

OSCHINA
登录后可查看更多优质内容
返回顶部
顶部