小编Rom*_*n C的帖子

用户注册的确认电子邮件如何运作?

当您在任何网站上注册时,您会收到一封电子邮件,其中包含注册时提供的电子邮件地址收件箱中的确认链接.只有当您单击此链接时,您才能登录.

这是如何工作的,我如何在Struts2中实现相同的功能?

java struts2

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

Android的StrictMode的生命周期是什么?

我正在尝试最小化我需要设置StrictMode的代码中的位置数.但我不确定我是否对以下内容有所帮助.

Android的StrictMode文档说您可以将它用于应用程序,活动和其他组件.我已经读过扩展Application类是不可取的,我不想仅仅为了启用StrictMode而扩展Application.但我不认为我必须这样做.

您可以使用两种策略:ThreadPolicy(用于线程)和VmPolicy(用于所有线程).所以看起来如果我在一个线程上设置一次StrictMode,那么我从哪里开始并不重要,并且此后将在该线程上报告违规,而不管StrictMode上是否有其他调用.我只需要在我想要检测到的违规行为之前从某个地方调用它.并且需要为我想要检查的应用程序中创建的任何新线程设置它.

我认为我想避免的是调用build()方法而不是我需要的.将StrictMode放在onCreate()我所有活动的开头,意味着build()将在该线程上被多次调用.如果我的应用程序中有一个Launcher活动,那么在该活动中设置StrictMode onCreate()应该足以满足应用程序的其余部分.真的吗?

其次,如果我的主要活动重新启动,即使应用程序没有死亡,技术上是否需要再次调用StrictMode?或者我的线程仍设置为报告违规?我认为在StrictMode周围做一个包装类的类可能有一些价值,如下所示:

public class MyStrictModeSettings {
    static private List<Long> setThreads = new ArrayList<Long>();

    // Prevent instantiation of this class
    private MyStrictModeSettings() {}

    static public synchronized void init() {
        try {
            Long tid = Thread.currentThread().getId();
            if(!setThreads.contains(tid)) {
                setThreads.add(tid);
                Class sMode = Class.forName("android.os.StrictMode");
                Method enableDefaults = sMode.getMethod("enableDefaults");
                enableDefaults.invoke(null);
            }
        }
        catch(Exception e) {
            // StrictMode not supported on this device, punt
            Log.v("StrictMode", "... not supported. Skipping...");
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

这样,在我的主要活动的onCreate()中,我可以简单地调用MyStrictModeSettings.init()并完成它.它也适用于2.3之前的Android版本.但它可能不值得.布拉德,你呢?谢谢.

编辑:由于VmPolicy适用于所有线程,从技术上讲,我只需要为每个应用程序设置一次,对吧?因此,当调用第二,第三等时间时,enableDefaults()会浪费精力重做VmPolicy吗?再一次,也许比试图避免额外呼叫更值得麻烦.

android android-strictmode

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

在InvokeProcess TF工作流活动中捕获regsvr32的输出

我有一个构建过程设置来使用团队构建来构建托管解决方案.此解决方案需要在构建解决方案之前向服务器注册非托管组件,因为我们通过COM与其进行交互.

我用来注册ComObject的活动(InvokeProcess)看起来像这样

regsvr32.exe /s ComObject.ocx
Run Code Online (Sandbox Code Playgroud)

我用来取消注册它的活动(InvokeProcess)看起来像这样

regsvr32.exe /u /s ComObject.ocx
Run Code Online (Sandbox Code Playgroud)

我还使用stdOutput和errOutput作为每个操作的消息添加了WriteBuildMessage和WriteBuildError两个InvokeProcess活动.我还确保将构建消息的重要性设置为高.

我的理解是,这应该将标准输出和错误输出重定向到这些日志记录活动中.

只要我没有将/maxcpucountMSBuild 的参数设置为大于1的任何值,registrion,build和unregistrion就可以正常工作.

一旦我将其设置为大于1的值,我们在过程结束时的清理脚本会在尝试删除相关文件时失败并显示此错误消息.

Access to the path '...\ComObject.ocx' is denied.'
Run Code Online (Sandbox Code Playgroud)

我认为正在发生的事情是取消注册活动无法从服务器取消注册ComObject.ocx,因为MSBuild在多个cpu运行时没有完成.然后,当我开始尝试从构建服务器中删除它时,它仍然在系统中注册,并且将因访问被拒绝错误而失败.

那么如何将regsvr32输出到stdOutput和errOutput,以便WriteBuildMessage和writeBuildError活动将在构建日志中正确显示它.如果我用不存在的文件调用regsvr32,我在构建日志中看不到任何内容.

我希望这是有道理的.

更新

这个问题的解决方案来自pantelif解决方案的一个小调整.我所做的是在抛出异常的if块中,我使用它作为消息执行WriteBuildError:

String.Format("ErrorMessage: {0}", New System.ComponentModel.Win32Exception( System.Runtime.InteropServices.Marshal.GetL??astWin32Error() ).ToString() )
Run Code Online (Sandbox Code Playgroud)

这允许我从regsvr32.exe获取错误并将其写入构建日志.

msbuild team-build tfsbuild tfs2010

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

如何在Java中手动设置数组?

如何手动将变量分配给数组?我在下面有一个代码片段.我不想手动放shortStraight[0] = "211100", shortStraight[1] = "021110",等等.有帮助吗?

private String [] shortStraight;

    public Sample () {
        shorty = new String [12];
                shorty = {211100, 021110, 002111, 121100, 112100, 111200, 012110, 011210, 011120, 001211, 001121, 001112 } //this line doesn't work.
Run Code Online (Sandbox Code Playgroud)

有帮助吗?

java

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

禁用弹簧自动装配

我有一个struts2.2和春季3.1的应用程序,我想禁用弹簧自动装配.我google了一下,发现我必须放在<beans>标签上default-autowire="no",但这似乎不起作用.

然后我知道我可以为每个<bean>标签声明这个:<bean autowire="no">,但这似乎也不起作用.

当我启用spring debug logger时,我可以看到很多这样的消息:

INFO:DEBUG [http-thread-pool-8080(3)](ConstructorResolver.java:739) - 通过构造函数将bean名称'com.common.actions.PopupAction'的类型自动装配到名为'intermedService'的bean

applicationConfig.xml中的相应条目是:

<beans default-autowire="no" 
       xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:p="http://www.springframework.org/schema/p"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
       http://www.springframework.org/schema/tx
       http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">

<bean id="PopupAction" scope="prototype" class="com.common.actions.PopupAction" autowire="no">
        <constructor-arg type="com.common.services.abs.iIntermedService" ref="intermedService"/>
        <constructor-arg type="com.common.services.abs.iLocationService" ref="locationService"/>
        <constructor-arg type="com.common.services.abs.iUserService" ref="userService"/>
        <constructor-arg type="com.common.services.abs.iPhoneService" ref="phoneService"/>
    </bean>
Run Code Online (Sandbox Code Playgroud)

为什么春天尝试自动装配这个动作,只要我在这里定义了依赖并且我定义了auto-wire="no"?

或者这条消息告诉我接线是通过类型通过构造函数(我想要的)和"按类型自动装配"来表示从4个参数中他将mediumService与我的变量中间服务匹配(而不是按顺序或其他) ?

spring struts2 autowired struts2-spring-plugin

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

存储Integer和array [String]值的最佳数据结构是什么?

我需要一个数据结构来存储许多与可变大小的字符串数组关联的整数值。例如,这就是我所拥有的-

ADDRESS   INSTRUCTION
64        ADD R1, R0, R0 
68        BGTZ R2, #32
.         .
.         .
.         .
124       J #116
Run Code Online (Sandbox Code Playgroud)

我想获取一个我认为应该基于ADDRESS值存储为字符串数组(不包括逗号和'#')的指令,更像是键值对。我认为这是存储它的一个好主意,或者,如果您可以建议我以更好的方式在内存中表示它,那就太好了。(我正在使用Java进行编码。)

一个具有推理(WHY?)和详细说明(HOW?)的良好数据结构(WHICH?)将非常好。

java arrays data-structures

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

Bootstrap工具提示无效

我的JavaScript:

<script>
    $(function(){
        $('a[rel=tooltip]').tooltip();
    });
?</script>
Run Code Online (Sandbox Code Playgroud)

我的HTML:

<br><br><br>This is an example of a sentence with a
<a href="#" rel="tooltip" title="This is the tooltip!">tooltip</a>!
Run Code Online (Sandbox Code Playgroud)

这不会显示Bootstrap 2.0工具提示,但会显示一些默认工具提示.

tooltip twitter-bootstrap

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

从 pdf 中获取页面并使用 itext 将其保存为图像文件

有一个pdf文件,我想将第二页作为图像导入并将其保存为jpeg文件。是否可能以及如何做到?

这是我导入页面的代码:

Document document = new Document();
File file = File.createTempFile("", "");
PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(file));
document.open();

final int backPage = 2;
PdfReader reader = new PdfReader(pdf.getAbsolutePath());
PdfImportedPage importedPage = writer.getImportedPage(reader, backPage);
com.lowagie.text.Image image = com.lowagie.text.Image.getInstance(importedPage);
Run Code Online (Sandbox Code Playgroud)

现在我得到了一个image实例,但我不知道如何将其写入 jpeg 文件。

java import image itext

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

在Java中使用SQL来设置值

初学者的问题:我正在尝试使用Java处理SQL来处理SQL中的两个不同属性的元组(对于大学未评估的实用).我与四个属性有关系,包括一种咖啡的名称,当周的销售额以及咖啡的总销售额.

我试图创建的代码将使用新数字更新销售和总字段.它意味着同时使用totalSales和Sales数组,添加它们,然后相应地更新关系中的两个属性.

到目前为止这是我的代码(我已经删除了所有明显/不必要的代码):

String updateTotalString = "update COFFEES set TOTAL = ? set SALES = ? where COF_NAME = ?";

String [] coffees = {"Columbian", "Earl Grey", "Kenyan", "Nescafe"};
int [] totalSales = {400,650,340,1000};
int[] sales = {50,75,100,100};

updateTotal = con.prepareStatement(updateTotalString);
    for (int i = 0; i < len; i++)
    {
        updateTotal.setInt(1, (sales[i] + totalSales[i]));
        updateTotal.setInt(2, sales[i]);
        updateTotal.setString(3, coffees[i]);
        updateTotal.executeUpdate();
    }
Run Code Online (Sandbox Code Playgroud)

不幸的是,运行它会给我一个SQL语法错误,专注于第一行(String updateTotalString).我有一种感觉,这与我试图在一行中做两组并且语法错误有关.
有人可以帮帮我吗?

java sql

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

try-catch不会捕获IOException

在下面的代码中,我得到了Unreachable catch block for IOException.此异常不会从try语句体错误(下划线)与扔IOException在} catch (IOException e){我究竟做错了什么?

class driver {

  public static void main(String[] args) {
    // TODO Auto-generated method stub
    Customer forrest = new Customer("Forrest Gump", 1,
        "42 New Street, New York, New York");
    Customer random = new Customer("Random Name", 2,
        "44 New Street, New York, New York");
    Customer customer[] = { null, forrest, random };
    int whichOption = 1;
    int id = 0;
    char action = ' ';
    char accSrc = …
Run Code Online (Sandbox Code Playgroud)

java try-catch ioexception

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