问题列表 - 第47460页

加密和解密存储在cookie中的信息

我需要安全地加密和解密有关cookie中用户(user_idpassword)的信息.

做这个的最好方式是什么 ?我需要哪些加密和解密功能?

我正在使用PHPMySQL示例将参加?

php mysql cookies

7
推荐指数
2
解决办法
2万
查看次数

在C++中如何区分整数和字符?

我目前正在学习C++,并且我被要求制作一个程序,该程序将计算对给定大小的存款支付的利息.其中一个要求是在输入非整数数据时显示错误消息.

但是我无法弄清楚如何检测是否输入了非整数数据.如果有人能提供一个如何解决这个问题的例子,将不胜感激!

c++ integer character

1
推荐指数
1
解决办法
2599
查看次数

jQuery查找并替换字符串

我在网站上有一个特定的文本,让我们说"lollypops",我想用"marshmellows"替换这个字符串的所有出现.问题是我不知道文本的确切位置.我知道我可以这样做:

$(body).html($(body).html().replace('lollypops', 'marshmellows'));
Run Code Online (Sandbox Code Playgroud)

这可能会有效,但我需要尽可能少地重写HTML,所以我想的是:

  1. 搜索字符串
  2. 找到最近的父元素
  3. 仅重写最接近的父元素
  4. 甚至在属性中替换它,但不是全部,例如替换它class,但不是src

在示例中,我会有这样的结构

<body>
    <div>
        <div>
            <p>
               <h1>
                 <a>lollypops</a>
               </h1>
            </p>
            <span>lollypops</span>
        </div>
    </div>
    <p>
       <span class="lollypops">Hello, World!</span>
       <img src="/lollypops.jpg" alt="Cool image" />
    </p>
<body>
Run Code Online (Sandbox Code Playgroud)

在这个例子中,每次出现的"lollypops"都会被替换,只会<img src="...保持不变,而实际操作的唯一元素将是<a>两个<span>s.
有人知道怎么做这个吗?

javascript jquery jquery-selectors

72
推荐指数
5
解决办法
36万
查看次数

如何从std :: vector <char>构造一个std :: string?

缺少(显而易见的)构建C样式字符串然后使用它来创建std :: string,是否有更快/替代/"更好"的方式来从字符向量初始化字符串?

c++

108
推荐指数
5
解决办法
10万
查看次数

PrimeFaces和JasperReports

我正在尝试开发一个用于报告的Web应用程序,并且已经构建了一个包含EJB3 + primefaces的站点.现在,我正在努力将Jasperreport整合到主要方面...我没有找到关于这个主题的指导或讨论,我想这是不可能的?或者实际上这不是一种正确的方法吗?我实际上是开发JavaEE6的新手,不打算使用像spring和seam这样的框架.


模型

@Stateless
@LocalBean
public class BookEJB {
    // @Override
    public void printReport() throws ClassNotFoundException, IOException, JRException, SQLException {
        Connection connection;
        Map parameterMap = new HashMap();

        FacesContext ctx = FacesContext.getCurrentInstance();

        HttpServletResponse response = (HttpServletResponse) ctx
                .getExternalContext().getResponse();

        InputStream reportStream = ctx.getExternalContext()
                .getResourceAsStream("reports/report1.jasper");

        ServletOutputStream servletOutputStream = response.getOutputStream();
        Class.forName("com.mysql.jdbc.Driver");
        connection = DriverManager.getConnection("jdbc:mysql://localhost/bookdb?user=root&password=******");

        ctx.responseComplete();
        response.setContentType("application/pdf");

        JasperRunManager.runReportToPdfStream(reportStream, servletOutputStream, parameterMap, connection);

        connection.close();
        servletOutputStream.flush();
        servletOutputStream.close();

    }
}
Run Code Online (Sandbox Code Playgroud)

调节器

@ManagedBean(name = "bookCtrl")
@RequestScoped
public class BookController {

    @EJB
    private BookEJB bookEJB;

    public void doPrintReport() throws ClassNotFoundException, …
Run Code Online (Sandbox Code Playgroud)

java jsf glassfish jasper-reports primefaces

6
推荐指数
1
解决办法
1万
查看次数

在javascript中处理java对象

我在我的JavaScript中使用Ajax,并在响应中设置以下类的对象数组:

public class RetrieveTempSecVersions {

    private String templateName;
    private int[] versionNumber;

    public String getTemplateName() {
        return templateName;
    }

    public void setTemplateName(String templateName) {
        this.templateName = templateName;
    }

    public int[] getVersionNumber() {
        return versionNumber;
    }

    public void setVersionNumber(int[] i) {
        this.versionNumber = i;
    }
}
Run Code Online (Sandbox Code Playgroud)

使用:

aoRes.setContentType("text/xml");
aoRes.setHeader("Cache-Control", "no-cache");
aoRes.getWriter().write(template[]);
Run Code Online (Sandbox Code Playgroud)

现在我想将模板数组中的所有元素及其详细信息读入我的JavaScript中.

任何人都可以帮我怎么做?

javascript java ajax

7
推荐指数
1
解决办法
7659
查看次数

用php regex获取youtube播放列表id

我正在尝试id从url中获取播放列表并将其保存到新变量中.例如,如果用户将其输入到表单中,然后提交该表单

http://www.youtube.com/watch?v=A7izsd5IXq8&playnext=1&list=PL6753173C0F0BE9ED

我只想抓住PL6753173C0F0BE9ED并将其保存到一个新变量中.我试图使用爆炸来做这个,所以它保存了一切后,&list=但我没有太多运气.

有什么想法吗?

谢谢您的帮助!

php regex youtube playlist

1
推荐指数
1
解决办法
3664
查看次数

UIScrollview中的UIWebview无法正常工作

当我在scrollView中插入一个UIWebView比在页面加载之前插入uiscrollview工作但是一旦我们加载页面,scrollView就不起作用了.如何解决这个问题?

谢谢

iphone objective-c

2
推荐指数
1
解决办法
1796
查看次数

打开xml excel读取单元格值

我正在使用Open XML SDK打开Excel xlsx文件,并尝试读取每个工作表中位置A1的单元格值.我使用以下代码:

using (SpreadsheetDocument spreadsheetDocument = SpreadsheetDocument.Open(openFileDialog1.FileName, false))
{
    var sheets = spreadsheetDocument.WorkbookPart.Workbook.Descendants<Sheet>();

    foreach (Sheet sheet in sheets)
    {
        WorksheetPart worksheetPart = (WorksheetPart)spreadsheetDocument.WorkbookPart.GetPartById(sheet.Id);
        Worksheet worksheet = worksheetPart.Worksheet;

        Cell cell = GetCell(worksheet, "A", 1);

        Console.Writeline(cell.CellValue.Text);
     }
}

private static Cell GetCell(Worksheet worksheet, string columnName, uint rowIndex)
{
     Row row = GetRow(worksheet, rowIndex);

     if (row == null)
         return null;

     return row.Elements<Cell>().Where(c => string.Compare
               (c.CellReference.Value, columnName +
               rowIndex, true) == 0).First();
}

// Given a worksheet and a row index, return …
Run Code Online (Sandbox Code Playgroud)

c# openxml openxml-sdk

47
推荐指数
3
解决办法
7万
查看次数

Java:null比较总是产生错误:不正确的警告?

有趣的情况.我有一段代码创建了几个ZipOutputStreams.在我考虑写任何东西之前作为安全检查,我检查我的输出流是否已正确初始化:

ZipOutputStream countStream = null;
File countFile = null;
// other files

try {
    countFile =
    new File(savePath.getCanonicalPath() + savePath.separator + outputTag
        + "_COUNT_OUTPUTS.zip");
    // other files
} catch (Exception e) {
    outputLog.add("UNABLE TO FIND SAVE PATH");
    return util.FILE_INVALID;
}

try {
    // prepare outputs
    if (countFile.exists() == true) {
    countFile.delete();
    } else {
    }
    countStream = new ZipOutputStream(new FileOutputStream(countFile));
    // other files
} catch (Exception e) {
    e.printStackTrace();
    outputLog.add("UNABLE TO CREATE OUTPUT FILES");
    return util.FILE_SAVE_FAIL;
}

if (countStream == …
Run Code Online (Sandbox Code Playgroud)

java zip warnings outputstream

4
推荐指数
2
解决办法
2090
查看次数