小编Dón*_*nal的帖子

Internet Explorer 6测试

有没有办法在已经安装了Firefox和Internet Explorer7的计算机上测试Internet Explorer 6中的网站,而没有:

  • 使用VM-ware
  • 卸载Internet Explorer 7并安装Internet Explorer 6(如果可能的话)

重复

testing internet-explorer cross-browser

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

JSTL中的test属性<c:if>标记

我在JSP中看到了类似下面的代码

<c:if test="<%=request.isUserInRole(RoleEnum.USER.getCode())%>">
    <li>user</li>
</c:if>
Run Code Online (Sandbox Code Playgroud)

我的困惑在于test属性值中出现的"=" .我的理解是,包含在其中的任何内容<%= %>都会打印到输出中,但是分配给test的值肯定必须是布尔值,那么为什么这样做呢?

对于奖励积分,有没有办法更改上面的属性值,使其不使用scriptlet代码?据推测,这意味着使用EL代替.

干杯,唐

java jsp jstl

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

基于注释的Spring bean验证

我正在研究一种基于注释的方法来使用spring模块验证Spring bean .在本教程中,以下bean(省略了getters和setter)用作示例:

public final class User {  

  @NotBlank  
  @Length(max = 80)  
  private String name;  

  @NotBlank  
  @Email  
  @Length(max = 80)  
  private String email;  

  @NotBlank  
  @Length(max = 4000)  
  private String text;  
}
Run Code Online (Sandbox Code Playgroud)

如果违反特定验证规则,则使用的错误消息应遵循以下格式:

bean-class.bean-propery[validation-rule]=Validation Error message
Run Code Online (Sandbox Code Playgroud)

上面显示的类的示例包括:

User.email[not.blank]=Please enter your e-mail address.  
User.email[email]=Please enter a valid e-mail address.  
User.email[length]=Please enter no more than {2} characters.
Run Code Online (Sandbox Code Playgroud)

消息键包含类名的事实存在一些问题:

  1. 如果重命名该类,则还需要更改消息键
  2. 如果我有另一个类(例如Person),其电子邮件属性与User.email相同,我需要复制消息,例如

    Person.email [not.blank] =请输入您的电子邮件地址.
    Person.email [email] =请输入有效的电子邮件地址.
    Person.email [length] =请输入不超过{2}个字符.

实际上,文档声称可以为特定规则(例如@Email)配置默认消息,如下所示:

email=email address is invalid
Run Code Online (Sandbox Code Playgroud)

如果找不到规则的特定于bean的消息,则应使用此缺省消息.但是,我的经验是,这根本不起作用.

避免重复消息的另一种机制是将错误消息的密钥传递给规则注释.例如,假设我已为@Email规则定义了以下默认错误消息

badEmail=Email address is …
Run Code Online (Sandbox Code Playgroud)

java validation spring-modules

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

Hibernate/GORM:flush()不处理集合

我在Grails应用程序中进行了集成测试,当我尝试保存类型的实体时失败 Member

invitingMember.save(flush: true)
Run Code Online (Sandbox Code Playgroud)

这引发了以下异常

org.hibernate.AssertionFailure:在com.mycompany.member.MemberConnectionService.addOrUpdateContact(MemberConnectionService.groovy:939)中,flush()未处理集合[com.mycompany.facet.Facet.channels].

在事务的早期,我将一个对象添加到集合属性中invitingMember.我的猜测是异常在上面的行中抛出,因为只有在这一点上才会保留添加到集合中的对象.

java grails hibernate grails-orm

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

bash脚本中的mkdir错误

以下是我在Windows上运行在cygwin下的bash脚本的一个片段:

deployDir=/cygdrive/c/Temp/deploy

timestamp=`date +%Y-%m-%d_%H:%M:%S`
deployDir=${deployDir}/$timestamp

if [ ! -d "$deployDir" ]; then
    echo "making dir $deployDir"
    mkdir -p $deployDir
fi
Run Code Online (Sandbox Code Playgroud)

这会产生如下输出:

making dir /cygdrive/c/Temp/deploy/2010-04-30_11:47:58
mkdir: missing operand
Try `mkdir --help' for more information.
Run Code Online (Sandbox Code Playgroud)

但是,如果我/cygdrive/c/Temp/deploy/2010-04-30_11:47:58在命令行上键入它成功,为什么同一命令在脚本中不起作用?

谢谢,唐

bash shell mkdir

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

依赖注入servlet监听器

在我的Stripes应用程序中,我定义了以下类:

MyServletListener implements ServletContextListener, HttpSessionListener, HttpSessionAttributeListener {

  private SomeService someService;

  private AnotherService anotherService;

  // remaining implementation omitted
} 
Run Code Online (Sandbox Code Playgroud)

此应用程序的服务层使用Spring来定义XML文件中的一些服务bean并将其连接在一起.我想注入实现SomeServiceAnotherService进入的bean,MyServletListener这可能吗?

java spring stripes dependency-injection

14
推荐指数
2
解决办法
7705
查看次数

使用Grails Spring Security自动登录

我的Grails应用程序正在使用Spring Security插件.我需要以编程方式登录用户,而且我无法访问他们的密码.我尝试了以下,当使用Acegi插件(Spring Security插件的祖先)时,它应该有效:

// automatically login a user and assign them the USER role. 
// In my app, the email address is also the username
GrantedAuthority[] auths = [new GrantedAuthorityImpl('USER')]
SecurityContextHolder.context.authentication 
        = new UsernamePasswordAuthenticationToken(email, 'unknown', auths)
Run Code Online (Sandbox Code Playgroud)

看起来这几乎有效,因为如果我springSecurityService.principal在执行上述操作后调用,我会收回自动登录用户的电子邮件地址.但是,如果我打电话,springSecurityService.currentUser我会收到错误.此错误的根本原因是:

SpringSecurityUtils.securityConfig.userLookup.userDomainClassName
Run Code Online (Sandbox Code Playgroud)

返回"Person",它不是我的用户类的名称.各种标签<sec:loggedInUser>也不起作用,大概是出于同样的原因.

我想知道这个问题是否与我使用预先存在的用户和角色域类(而不是插件生成的类)的事实有关?如果用户通过在表单中​​输入用户名和密码(而不是以编程方式)登录,则一切似乎都能正常工作.

更新

按照Burt的建议,我将上面的代码替换为:

springSecurityService.reauthenticate(email)
Run Code Online (Sandbox Code Playgroud)

但我仍然在这些线路上出现错误 SpringSecurityService.getCurrentUser()

String className = SpringSecurityUtils.securityConfig.userLookup.userDomainClassName
grailsApplication.getClassForName(className).get(principal.id)
Run Code Online (Sandbox Code Playgroud)

因为className设置为"Person",而不是我的User类的名称.

grails spring-security

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

Grails域模型中的继承会导致重复的外键

在我的Grails 2.5.0应用程序的域模型中,我有两个类Income,Benefit它们具有相同的属性.我想将它们存储在单独的数据库表中,但将公共字段移动到基类中.我提出的模型是:

class Assessment {

    Date dateCreated = new Date()
    User user

    static hasMany = [incomes: Income, benefits: Benefit]
}

class Benefit extends IncomeSource {}

class Income extends IncomeSource {}

abstract class IncomeSource {

    String name
    BigDecimal amount
    PaymentFrequency frequency

    static belongsTo = [assessment: Assessment]

    static mapping = {
        tablePerHierarchy false
    }
}
Run Code Online (Sandbox Code Playgroud)

这将导致之间的关系要产生的下表AssessmentBenefit

在此输入图像描述

表对之间的关系创建AssessmentBenefit是(勿庸置疑)相同.

而不是assessment_benefitassessment和之间有一个连接表benefit,我宁愿assessment_idbenefit表中有一个外键,从而不需要连接表.

如何更改我的域模型以实现此目的?

grails hibernate grails-orm

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

在web.xml中声明JSP taglib指令

我似乎记得读过可以声明taglib指令,例如:

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
Run Code Online (Sandbox Code Playgroud)

在web.xml中.这消除了在使用taglib的每个JSP文件中复制此指令的需要.有人能告诉我如何将这些指令添加到web.xml中吗?

java jsp jsp-tags

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

运算符中的Groovy如何工作?

在不同的情况下,Groovy"in"运算符似乎意味着不同的东西.有时x in y意味着y.contains(x),有时它似乎打电话y.isCase(x).

Groovy如何知道要调用哪一个?是否有一个特定的类或一组类Groovy知道哪些使用.contains方法?或者是由于某个对象上存在方法而触发的行为?是否有任何情况下in运算符完全变为其他东西?

groovy operators in-operator

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