问题列表 - 第43544页

如何在Windows机器上找到JDK的安装位置?

我需要知道JDK在我的机器上的位置.

Java -versioncmd中运行时,它将版本显示为"1.6.xx".要在我的机器上查找此SDK的位置,我尝试使用echo %JAVA_HOME%但它只显示'JAVA_HOME'(因为我的环境变量中没有设置'JAVA_PATH'var).

java windows

288
推荐指数
16
解决办法
86万
查看次数

TempData始终为空

我想使用TempData在Post和后续重定向之间存储消息,但TempData始终为空.

我有BaseContoller为传递TempData提供了一些基础设施.简化的代码如下所示:

public abstract class BaseController : Controller
{
  public const string AuditMessagesKey = "AuditMessages";

  private List<InformationMessage> _informationMessages = new List<InformationMessage>();

  protected BaseController()
  {
    // I also tried this in overriden Initialize
    ViewData[AuditMessagesKey] = GetAuditMessages();
  }

  protected void AddAuditMessage(InformationMessage message)
  {
    if (message == null)
      return;

     _informationMessages.Add(message);
  }

  protected override void OnResultExecuting(ResultExecutingContext filterContext)
  {
    base.OnResultExecuting(filterContext);

    if (filterContext.Result is RedirectToRouteResult)
    {
      // I see that messages are stored into TempData
      TempData[AuditMessagesKey] = _informationMessages;
      // This also doesn't help
      // TempData.Keep(AuditMessagesKey);
    } …
Run Code Online (Sandbox Code Playgroud)

asp.net-mvc tempdata asp.net-mvc-2

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

TransactionScope抛出异常

我确定这是一个非常基本的问题,但我无法在谷歌找到任何解决方案.

当我试图使用该代码块时,它会抛出一个异常,即'System.Activities.Statements.TransactionScope':在using语句中使用的类型必须可以隐式转换为'System.IDisposable'

using (TransactionScope trans = new TransactionScope()) { }

简单地说,我想在Linq代码中使用TransactionScope.

感谢和问候

c# linq transactionscope

5
推荐指数
2
解决办法
3007
查看次数

棘手的WPF绑定

我无法在Silverlight 4中进行简单但棘手的WPF绑定(WP7开发)

我有以下代码:

Class People{
    public string firstname;
    public string lastname;
}

Class DataSource{
    public static List<People> people; // consider this as a list filled with objects already
}
Run Code Online (Sandbox Code Playgroud)

我正在尝试将人员列表放入ListBox,这是我尝试过的xaml:

            <ListBox x:Name="peoplelistbox" Margin="0,0,-12,0" ItemsSource="{Binding DataSource.people}">
                <ListBox.ItemTemplate>
                    <DataTemplate>
                      <StackPanel Margin="0,0,0,17" Width="432">
                            <TextBlock Text="{Binding firstname}" TextWrapping="Wrap"/>
                            <TextBlock Text="{Binding lastname}" TextWrapping="Wrap"/>
                      </StackPanel>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>
Run Code Online (Sandbox Code Playgroud)

但不幸的是我的列表框仍然是空的.我究竟做错了什么 ?

先感谢您 :)

干杯,米卢德B.

data-binding wpf binding listbox windows-phone-7

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

无法使用Java从xml读取特殊字符

当我尝试使用SAX解析器从Java读取xml时,无法读取特殊字符后存在的元素中的内容

例如:

<title>It's too difficult</title>
Run Code Online (Sandbox Code Playgroud)

使用SAX解析器读取之后,它只是显示

如何处理特殊字符。我的示例代码如下

    package com.test.java;

import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;

import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
public class ReadXMLUsingSAXParser {




  public static void main(String argv[]) {

   try {

      SAXParserFactory factory = SAXParserFactory.newInstance();
      SAXParser saxParser = factory.newSAXParser();

      DefaultHandler handler = new DefaultHandler() {

      int titleCount;
      boolean title = false;
      boolean description = false;

      public void startElement(String uri, String localName,
         String qName, Attributes attributes)
         throws SAXException {

        // System.out.println("Start Element :" + qName);


         if (qName.equalsIgnoreCase("title")) {
            title = …
Run Code Online (Sandbox Code Playgroud)

java

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

得分/存储板球比赛

这个问题的两个部分:

  • 是否有任何现有的文件格式或软件库可用于评分,存档和/或分析板球游戏?
  • 是否有适用于记录板球比赛所有细节的数据库模式示例?

database database-design file-format

15
推荐指数
2
解决办法
4647
查看次数

JavaScript:有一个utils库吗?

我想知道如果这样的库中存在,在库仅包含的应用程序的通用功能的集合,例如trim,indexOf(数组)map,each,typeOf等...

我知道jQuery提供了我上面列出的一些函数,但我正在寻找一些纯粹为此而设计的东西(我真的不需要在服务器端运行node.js的jQuery,也不需要如果我正在编写一个非jQuery相关的JavaScript库,我想依赖它.我最近开始为将来的复制/粘贴收集各种各样的功能,但我的猜测是,除非有人向我展示,否则还有许多我甚至不知道要寻找或想到使用的其他功能.

javascript

6
推荐指数
2
解决办法
9764
查看次数

如何将子视图与父NSView的中心对齐

我正在开发一个程序,我在其中以编程方式将NSImageView添加到自定义NSView类.在创建图像视图时,我传递父容器的框架.

-(NSImageView *)loadNSImage:(NSString *)imageName frame:(NSRect)frame{
    imageName = [[NSBundle mainBundle] pathForResource:imageName ofType:@"png"];
    NSImage *image = [[NSImage alloc] initWithContentsOfFile:imageName]; 
    NSImageView *imageView = [[NSImageView alloc]initWithFrame:frame];
    [imageView setImage:image];
    [imageView setImageScaling:NSImageScaleProportionallyUpOrDown];
    [imageView setAutoresizingMask:NSViewHeightSizable | NSViewWidthSizable | NSViewMaxXMargin | NSViewMaxYMargin | NSViewMinXMargin | NSViewMinYMargin];
    [imageView setImageAlignment:NSImageAlignCenter];
    [image release];
    return imageView;
}
Run Code Online (Sandbox Code Playgroud)

然后我使用该addSubView方法将其添加到自定义视图中.问题是图像粘在父视图的左下角.如何将此图像放在父视图的中心?

我已经尝试在帧原点上添加一个偏移量,但是当调整窗口大小时,或者加载了不同大小的图像时,这实际上并不起作用.

任何帮助,将不胜感激.

macos cocoa

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

在部分类中实现接口

考虑一个实现大量接口的类,使用partial class定义在单独的文件中实现每个接口是否有意义?

这是滥用语言功能还是我不知道的成语?

.net c# interface code-organization partial-classes

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

RMagick:缩放和调整缩略图的大小

我想调整图像大小/缩放图像.原件尺寸与300x200或512x600不同.我想将图像调整为100x100,但不要从图像或变化率中裁剪任何东西.理想情况下,图像首先将长边缩放到100(纵横比),然后用白色填充较小的边缘.

 .---------.
 |- - - - -|
 |  IMAGE  |
 |- - - - -|
 '---------'
Run Code Online (Sandbox Code Playgroud)

我不使用Paperclip或Rails,只使用RMagick.

image rmagick

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