我想为我的应用程序实施评级系统来评估事件.
我一直在搜索,我认为这是我需要做的列表来实现评级系统,我还会附上我发现的关于每个点的内容.
找到一个合适的算法:我已经搜索了很多,但到目前为止还没有找到一个好的算法
确定我将要使用的数据库结构
实现插件并将轮询结果发送到数据库所需的c#代码和JavaScript代码
我想就是这样!如果您有任何建议或要点,请分享.
这与简单的文件复制操作代码有关.我的要求是只将新文件从源文件夹复制到目标文件夹,所以在复制文件之前,我检查:
在此之后,我继续复制操作.
但是,我随机获得一个IOException,声明"文件<filename>已经存在".
现在,我在2台服务器上运行此代码(作为win服务的一部分),所以我愿意承认,也许,只是可能,在Server1检查条件并继续复制文件的短暂间隔内,Server2复制它到目标,导致Server1上的IOException.
但是,我有几千个文件被复制,我得到了数千个这个错误.这怎么可能?我错过了什么?这是代码:
try
{
if(File.Exists(String.Format("{0}\\{1}",pstrSourcePath,strFileName)) && !File.Exists(String.Format("{0}\\{1}",pstrDestPath,strFileName)))
File.Copy(String.Format("{0}\\{1}",pstrSourcePath,strFileName),String.Format("{0}\\{1}",pstrDestPath,strFileName))
}
catch(IOException ioEx)
{
txtDesc.Value=ioEx.Message;
}
Run Code Online (Sandbox Code Playgroud) 我编写了一个ViewScoped Managed-Bean,每当我在webbrowser中刷新页面时,Managed-Bean似乎都被重新创建,文章为null,它会加载一个新的文章对象,依此类推.对我来说,它看起来与RequestScoped的行为相同.
我将Eclipse IDE用于Java EE开发人员,最新的JDK,Apache Tomcat 7.0.8和Mojarra 2.0.3.
怎么了?
托管bean:
...
import javax.annotation.PostConstruct;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
...
@ManagedBean
@ViewScoped
public class CreateArticle {
@ManagedProperty(value = "#{index.facade}")
private PersistenceFacade facade;
private Article article;
private Vector<ArtCategory> artcat;
public CreateArticle() {
artcat = ArtCategory.listArtCat();
}
@PostConstruct
public void postCreateArticle() {
if (article == null) {
try {
article = facade.createArticle();
} catch (DAOException e) {
e.printStackTrace();
}
}
}
public void setFacade(PersistenceFacade facade) {
this.facade = …Run Code Online (Sandbox Code Playgroud) 在编写一个简单的远程测试时,我遇到了一个涉及DBI(双括号初始化)的令人惊讶的情况,我一直无法完全理解,所以我会请求一些帮助.
请考虑以下代码:
public class RemotingTest {
@Autowired
private RemotingTestController remotingTestController;
//DBI
List<SomeBean> mockList = new ArrayList<SomeBean>(){{
add(MockFactoryBean.getMockBean());
}};
@Test
public void testRemoting() {
try {
// controller code is not relevant - it simply passes this list
// via Spring's HttpInvokerProxyFactoryBean to a session facade which then
// passes the list further down the SOA stack...
String result = remotingTestController.createBeanRemotely(mockList);
log.debug(result);
} catch (Exception e) {
fail();
e.printStackTrace();
}
}
Run Code Online (Sandbox Code Playgroud)
}
此代码在运行时发生爆炸,出现以下错误,这对我没有意义:
java.io.NotSerializableException: org.stackoverflow.RemotingIntegrationTest at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1164) at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1518) <<stacktrace snipped …
我遇到了这个Java程序,它以意想不到的方式运行.以下程序计算int数组中元素对之间的差异.
import java.util.*;
public class SetTest
{
public static void main(String[] args)
{
int vals[] = {786,678,567,456,
345,234,123,012};
Set<Integer> diffs = new HashSet<Integer>();
for(int i=0; i < vals.length ; i++)
for(int j = i; j < vals.length; j++)
diffs.add(vals[i] - vals[j]);
System.out.print(diffs.size());
}
}
Run Code Online (Sandbox Code Playgroud)
如果我们分析它似乎设置大小应该是8,这是数组的大小.但是,如果你运行这个程序,它打印14.发生了什么?任何的想法?
先感谢您.
答:这种奇怪的行为发生是因为如果我们将数组改为12则数组中的012变为八进制,然后按预期打印8.
课程:永远不要用零填充整数文字.
此功能用于我列出搜索结果的视图中.在我的搜索表单中,我有一些ModelChoiceFields可以通过外键进行搜索.平时的工作流程是指把我们当前的搜索更加精确,所以禁用了很多不相关的结果,我想删除,如果没有其他的搜索参数改变这将返回任何结果条目.
我正在使用对象查询集来限制某些下拉列表中的命题.我使用这些下拉列表来过滤外键我的对象列表.
我的filter函数参数现在是一个Objects查询集:
class MySearchForm(Form):
things = ModelChoiceField(queryset=models.Thing.objects.none())
def __init__(self, *args, **kwargs):
my_objects_queryset = kwargs.pop('my_objects_queryset',models.Thing.objects.all())
super(MySearchForm, self).__init__(*args, **kwargs)
self.fields['things'].queryset = \
models.Thing.objects.filter(object__in=my_objects_queryset).distinct()
Run Code Online (Sandbox Code Playgroud)
我的问题是如何从现有的query_set中删除'where close'.在这里,我想从my_objects_queryset中删除哪里关闭哪个过滤器thing = ForeignKey(models.Thing)
可能吗?
类似于列出我们的查询集的所有过滤器并在运行中编辑/删除它们的方法.
我一直在关注http://www.atinfinity.info/wiki/index.php?OpenCV/Using%20OpenCV%202.2%20on%20iOS%20SDK%204.2上的简单指南(使用旧指南我也读过在http://niw.at/articles/2009/03/14/using-opencv-on-iphone/en),以获得编译在iOS 4.2的工作OpenCV2.2.一切顺利,直到我试图建立.当我运行以下内容时:
lc:opencv_simulator leonard$ ../opencv_cmake.sh Simulator ../../OpenCV-2.2.0/
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
ld: warning: in /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.2.sdk/usr/lib/libSystem.dylib,
file was built for i386 which is not the architecture being linked (x86_64)
Run Code Online (Sandbox Code Playgroud)
这是使用(显然在其他设置中):
-D CMAKE_OSX_ARCHITECTURES="i386"
Run Code Online (Sandbox Code Playgroud)
我在OSX 10.6上看到i386被视为默认值,因此它使用系统默认值(但是x86_64).我也读过我可以用的:
export CFLAGS=-m32
export CPPFLAGS=-m32
Run Code Online (Sandbox Code Playgroud)
但这也不起作用.
有任何想法吗?
HttpUtility.UrlEncode("!!!test", Encoding.GetEncoding("windows-1251"))
Run Code Online (Sandbox Code Playgroud)
它不编码!来%21-为什么?
我有这个域名:
class Participation {
ParticipationStatus status
}
class ParticipationStatus{
String name
Date creationDate
}
Run Code Online (Sandbox Code Playgroud)
我创建了一个查询:
Participation.createCriteria().list{
createAlias("status","statusAlias")
order "statusAlias.creationDate"
projections{
groupProperty "id"
}
}
Run Code Online (Sandbox Code Playgroud)
但是我收到一个错误:引起:java.sql.SQLException:ORA-00979:N'est pas une expression GROUP BY
我2天前在这个查询grrrr上工作了!;-)
非常感谢
我想使用Spring Cache功能,但我不知道这个模块有什么依赖.我的配置如下:
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:cache="http://www.springframework.org/schema/cache"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache.xsd">
...
<mvc:annotation-driven />
<cache:annotation-driven />
Run Code Online (Sandbox Code Playgroud)
但是<cache:annotation-driven />没有被认可.它给出了这个错误:
cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'cache:annotation-driven'
Run Code Online (Sandbox Code Playgroud)
我认为这是因为我没有Spring模块的jar文件,因为我没有添加所有(我真正需要它时添加它们).
要使Spring Cache工作,需要哪些弹簧模块罐?或者我可以在哪里找到这些信息?
谢谢