我需要使用ajax将变量添加到会话状态,当我尝试它时它不起作用.任何人都可以帮助我.当我点击Button It重定向到Travellerinfo.aspx页面时
下面是我的test.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="test.aspx.cs" Inherits="hotelbeds.test" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>jQuery UI Tooltip - Custom animation demo</title>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css" />
<script type="text/javascript">
function testbook(hotelcode) {
$.ajax({
type: "POST",
url: "test.aspx/addSession",
data: "{'hotelcode':'" + hotelcode + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
window.location.href = "Hotelresul.aspx";
},
error: function (err) {
window.location.href = …
Run Code Online (Sandbox Code Playgroud) 我有问题重定向到jsp.我把我的servlet代码放在下面.而且我也把错误日志.任何人都可以帮我解决问题.如果您需要进一步的细节,请在下面评论.我在其他servlet中做了同样的工作.
public class DoctorServlet extends HttpServlet {
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String sDocId=request.getParameter("doctorId");
Integer dId=Integer.parseInt(sDocId);
String speciality=request.getParameter("speciality");
String experience=request.getParameter("experience");
String qualification=request.getParameter("qualification");
String sempId=request.getParameter("employeeId");
Integer empId=Integer.parseInt(sempId);
String action=request.getParameter("method");
Doctors d=new Doctors();
if(action.equalsIgnoreCase("add")){
d.setDocId(dId);
d.setEmpId(empId);
d.setExp(experience);
d.setSumOfQn(qualification);
d.setSpeciality(speciality);
try {
boolean result=new Doctors().insertDoctor(d);
if(result==true){
request.setAttribute("add","sucess");
}
request.getRequestDispatcher("doctor_result.jsp").forward(request, response);
response.sendRedirect("doctor_result.jsp");
} catch (SQLException ex) {
Logger.getLogger(DoctorServlet.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
Aug 23, 2012 12:29:50 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [DoctorServlet] in context …
Run Code Online (Sandbox Code Playgroud) 我想使用 RegEx 将 url 分成两部分。我已将 xml 响应保存到数据表中,并使用 foreach 遍历每一行。当我使用 regEx 的数据表值时,只有 0 可用。当我使用数组索引 1 时,它给出以下异常。
System.IndexOutOfRangeException: Index was outside the bounds of the array.
Run Code Online (Sandbox Code Playgroud)
以下是给出和异常。
foreach (DataRow row in ndt.Rows)
{
string imgurl =row["image1"].ToString();
String[] fimgurl = Regex.Split(imgurl, @"small/");
String simgurl = fimgurl[1];
}
Run Code Online (Sandbox Code Playgroud)
下面它工作没有任何问题。
foreach (DataRow row in ndt.Rows)
{
//TextBox1.Text = row["ImagePath"].ToString();
string imgurl ="http://www.hotelbeds.com/giata/small/12/124356/124356a_hb_w_001.jpg";
String[] fimgurl = Regex.Split(imgurl, @"small/");
String simgurl = fimgurl[1];
}
Run Code Online (Sandbox Code Playgroud)
我在我的数据表中保存了与字符串相同的 url。我找不到这有什么问题。任何人都可以帮我解决这个问题吗?
我需要优化我的代码.我有一些重复代码.但我想优化它.任何人都可以帮我优化我的代码.我怎样才能为此增加常用功能?
foreach (var item in hotellocation.GroupBy(x => x).ToDictionary(g => g.Key, g => g.Count()))
{
if (item.Key != "")
{
lstHotelLocation.Add(new HotelLocation()
{
Name = item.Key,
count = item.Value
});
}
}
//need to Apply to linq
foreach (var item in hoteltype.GroupBy(x => x).ToDictionary(g => g.Key, g => g.Count()))
{
if (item.Key != "")
{
lstHotelType.Add(new HotelTypeFilter()
{
Name = item.Key,
count = item.Value
});
}
}
Run Code Online (Sandbox Code Playgroud) c# ×3
asp.net ×2
ajax ×1
asp.net-mvc ×1
html ×1
java ×1
java-ee ×1
javascript ×1
jsp ×1
linq ×1
optimization ×1
regex ×1
servlets ×1