小编Jaa*_*nus的帖子

C++随机问题

测试

RandomNumberGenerator rng;
cout << rng() << endl;
Run Code Online (Sandbox Code Playgroud)

class RandomNumberGenerator {
public:
    unsigned long operator()(); 
};
Run Code Online (Sandbox Code Playgroud)

CPP

unsigned long operator()() {   // HERE IS ERROR
srand(time(NULL));
unsigned long r = rand();
return r;
}
Run Code Online (Sandbox Code Playgroud)

基本上我试图做一个随机数发生器.但得到一个错误:

C:\ CodeBlocks\kool\praks3\src\myfunctors.cpp | 5 | error:'long unsigned int operator()()'必须是非静态成员函数

c++ random

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

访问组合框值

我有一个组合框和一个按钮,该按钮使用从组合框获取的值来运行查询,但似乎没有获得正确的值。 在此处输入图片说明

我尝试使用

[Forms]![Kooli otsing]![Combobox] 
Run Code Online (Sandbox Code Playgroud)

要么

[Forms]![Kooli otsing]![Combobox].[Text]
Run Code Online (Sandbox Code Playgroud)

该查询不起作用,似乎无法从组合框获取值。因为它可以与普通的TextBox一起使用。

我添加了图片说明! 在此处输入图片说明

VBA编辑器的附加图片 在此处输入图片说明

错误和无注释自动添加的附加图片 在此处输入图片说明 在此处输入图片说明

ms-access vba

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

Java,Spring,Apache Tiles错误:无法解析名为'spring'的servlet中名为'contact'的视图

控制器:

@Controller
@SessionAttributes
public class ContactController {

    @RequestMapping(value = "/addContact", method = RequestMethod.POST) 
    public String addContact(@ModelAttribute("contact") 
                            Contact contact, BindingResult result) {

         System.out.println("First Name:" + contact.getFirstName() +
                 "Last Name:" + contact.getLastName());

     return "redirect:contacts.html";
    }

    @RequestMapping("/contact")
    public ModelAndView showContacts() {

        return new ModelAndView("contact", "command", new Contact());
    }
}
Run Code Online (Sandbox Code Playgroud)

这是我的tiles.xml:

<tiles-definitions>
    <definition name="base.definition"
        template="/WEB-INF/jsp/layout.jsp">
        <put-attribute name="title" value="" />
        <put-attribute name="header" value="/WEB-INF/jsp/header.jsp" />
        <put-attribute name="menu" value="/WEB-INF/jsp/menu.jsp" />
        <put-attribute name="body" value="" />
        <put-attribute name="footer" value="/WEB-INF/jsp/footer.jsp" />
    </definition>

    <definition name="contact" extends="base.definition">
        <put-attribute name="title" value="Contact Manager" /> …
Run Code Online (Sandbox Code Playgroud)

java spring apache-tiles

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

Java保存对象引用如何工作?

    String a = "test";
    String b = a;

    a = "wuut";

    System.out.println(b);
Run Code Online (Sandbox Code Playgroud)

打印出来 test

不应该b持有价值a,而不仅仅是拿它的价值?

Java是否与对象和东西一起工作?

java reference object

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

在eclipse中查找类来自哪个库

假设我的班级中有一个导入行:

import org.apache.log4j.Logger;
Run Code Online (Sandbox Code Playgroud)

我怎么知道它来自哪个图书馆?假设我有 maven 文件夹,其中包含大量库。

为什么? 我想在我的另一个项目中使用这个类/库,但我不知道要复制哪个 JAR。

eclipse import jar maven

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

在表或类似中使用两个主键

我有一张桌子Users.

我有一个自动增加长ID作为主要.现在我需要用户名也是唯一的.什么是最佳做法?

我应该只保留用户名并删除数字ID吗?我应该以某种方式使它们都独一无二吗?您有什么推荐的吗?

也许还应该提一下使用hibernate.

java database postgresql hibernate

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

Spring没有类型匹配的bean,预计至少有1个bean

得到错误

 No matching bean of type [foo.bar.service.AccountService] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
Run Code Online (Sandbox Code Playgroud)

我的服务:

public interface AccountService {

@Service
public class AccountServiceImpl implements AccountService {
Run Code Online (Sandbox Code Playgroud)

所以我应该得到实施

在哪里我想得到它:

public class CustomAuthentication implements AuthenticationProvider {

@Autowired
private AccountService accountService;
Run Code Online (Sandbox Code Playgroud)

在我的其他班级也做同样的事情,但它有效.

@Controller
public class AccountController {

@Autowired
private AccountService accountService;
Run Code Online (Sandbox Code Playgroud)

当我从我的那两行删除时CustomAuthentication,没有错误.

配置只是因为:

    <context:component-scan base-package="foo.bar" />
Run Code Online (Sandbox Code Playgroud)

java spring spring-mvc autowired

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

听取检查的bootstrap复选框

我使用的引导主题叫做:Core Admin http://wrapbootstrap.com/preview/WB0135486

这是我写的代码:

<div class="span6">
    <input type="checkbox" class="icheck" id="Checkbox1" name="userAccessNeeded">
    <label for="icheck1">Needed</label>
</div>
Run Code Online (Sandbox Code Playgroud)

并且bootstrap生成这个代码:

<div class="span6">
<div class="icheckbox_flat-aero" style="position: relative;">
    <input type="checkbox" class="icheck" id="Checkbox7" name="userAccessNeeded" style="position: absolute; opacity: 0;">
    <ins class="iCheck-helper" style="position: absolute; top: 0%; left: 0%; display: block; width: 100%; height: 100%; margin: 0px; padding: 0px; background-color: rgb(255, 255, 255); border: 0px; opacity: 0; background-position: initial initial; background-repeat: initial initial;"></ins>
</div>
<label for="icheck1" class="">Needed</label>
Run Code Online (Sandbox Code Playgroud)

这是结果: 在此输入图像描述

所以基本上它给我一个漂亮的复选框.每次我点击复选框,它都会checked向div 添加一个类:

 <div class="icheckbox_flat-aero checked" style="position: relative;">
Run Code Online (Sandbox Code Playgroud)

所以起初我想听这样改变的输入字段

$('input[type="checkbox"][name="userAccessNeeded"]').change(function () { …
Run Code Online (Sandbox Code Playgroud)

html javascript jquery twitter-bootstrap

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

ASP NET MVC OnException不被称为ApiController

我试图拦截所有异常,但是代码永远不会运行。我尝试将其放到GlobalFilters,也直接将其放到我的方法上。

我的属性:

[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = false, Inherited = false)]
public class HandleExceptionAttribute : HandleErrorAttribute 
{
    private ILog log = LogManager.GetLogger(typeof(HandleExceptionAttribute));

    public override void OnException(ExceptionContext filterContext) 
    {
        log.Info("inside on exception"); // this never appears
    }
}
Run Code Online (Sandbox Code Playgroud)

我的课:

public class Tester 
{
    [HandleException]
    public void Except() 
    {
        var asd = 0;
        var qwe = 1 / asd;              
    }
}
Run Code Online (Sandbox Code Playgroud)

除以零会给我一个异常,调试器会捕获它,我继续,但是没有任何内容写入日志文件。

记录器正常工作。其他日志出现在文件中。即使禁用调试,它也不会读取日志文件,因此这不是调试器的错误。

在IIS Express上运行它。Windows 7的。

编辑:

将东西移到控制器上。还是行不通

public class UserController : ApiController 
{
    private ILog log = LogManager.GetLogger(typeof(UserController));

    [HandleException] …
Run Code Online (Sandbox Code Playgroud)

c# asp.net-mvc exception-handling asp.net-mvc-4 asp.net-apicontroller

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

EF LINQ ToList非常慢

我正在使用ASP NET MVC4.5和EF6代码优先迁移.

我有这个代码,大约需要6秒钟.

var filtered = _repository.Requests.Where(r => some conditions); // this is fast, conditions match only 8 items
var list = filtered.ToList(); // this takes 6 seconds, has 8 items inside
Run Code Online (Sandbox Code Playgroud)

我认为这是因为关系,它必须在内存中构建它们,但事实并非如此,因为即使我返回0字段,它仍然很慢.

var filtered = _repository.Requests.Where(r => some conditions).Select(e => new {}); // this is fast, conditions match only 8 items
var list = filtered.ToList(); // this takes still around 5-6 seconds, has 8 items inside
Run Code Online (Sandbox Code Playgroud)

现在请求表非常复杂,关系很多并且有大约16k项.另一方面,筛选后的列表应该只包含8个项目的代理.

为什么ToList()方法这么慢?我实际上认为问题不在ToList()方法中,但可能是EF问题,或者设计问题不好.

有没有经历过这样的事情?

编辑: …

.net c# linq entity-framework ef-code-first

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