我正在尝试使用权限设置基于角色的安全性.我正在尝试与Spring-Security一起完成这项工作.
我不想设置ACL,因为它似乎对我的要求有点过分.
我只想拥有本文所述的简单权限和角色.遗憾的是,该文章没有描述如何实现给定的解决方案.
有人已经尝试过这个并且可以指出我正确的方向吗?也许还有另一篇描述实施的博客文章?
非常感谢你.
我想知道使用jUnit测试在下面的类中测试方法"pushEvent()"的最佳方法是什么.我的问题是,私有方法"callWebsite()"总是需要连接到网络.我怎样才能避免这个要求或重构我的课程,我可以在没有连接到网络的情况下测试它?
class MyClass {
public String pushEvent (Event event) {
//do something here
String url = constructURL (event); //construct the website url
String response = callWebsite (url);
return response;
}
private String callWebsite (String url) {
try {
URL requestURL = new URL (url);
HttpURLConnection connection = null;
connection = (HttpURLConnection) requestURL.openConnection ();
String responseMessage = responseParser.getResponseMessage (connection);
return responseMessage;
} catch (MalformedURLException e) {
e.printStackTrace ();
return e.getMessage ();
} catch (IOException e) {
e.printStackTrace ();
return e.getMessage (); …Run Code Online (Sandbox Code Playgroud) 我想创建一个自定义的JSF 2.0组件,但无法使其工作.我的组件定义如下:
@FacesComponent(value = "myCustomComponent")
public class CommaSeperatedOutput extends UIComponentBase { ... }
Run Code Online (Sandbox Code Playgroud)
taglib看起来像这样:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<facelet-taglib xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facelettaglibrary_2_0.xsd" version="2.0">
<namespace>http://www.company.com/tags</namespace>
<tag>
<tag-name>custom</tag-name>
<component>
<component-type>myCustomComponent</component-type>
</component>
</tag>
</facelet-taglib>
Run Code Online (Sandbox Code Playgroud)
我的faces-config看起来像这样:
<faces-config version="2.0" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd">
<application>
<el-resolver>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver>
</application>
</faces-config>
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
SEVERE: JSF1068: Component with componenttype myCustomComponent could not be instantiated.
javax.faces.FacesException: Expression Error: Named Object: myCustomComponent not found.
Run Code Online (Sandbox Code Playgroud)
不确定它是否重要,但我在这里使用Spring 3.1和JSF 2.1.所以依赖关系由Spring管理.
知道这里发生了什么吗?
解:
看起来Spring就是这里的坏人.我已从__CODE__组件中删除了注释,并在我的faces-config中定义了它,如下所示:
@FacesComponent(value = "myCustomComponent")
public class CommaSeperatedOutput extends UIComponentBase { …Run Code Online (Sandbox Code Playgroud) 如果数据库达到SQL Server Compact Edition的4GB限制会发生什么?这有特殊的例外吗?
我可以安全地捕获此事件或异常,并且假设创建一个新数据库吗?
我需要将一个非常大的xml文件压缩到尽可能小的大小.
我在C#工作,我更喜欢它是一些我可以通过我的代码访问的开源或应用程序,但我也可以处理一个算法.
谢谢!
我正在尝试使用Jersey开发restful API.我有一个特定的get操作的GET API,我的GET从同一个客户端同时进行.是否可以缓存响应?任何指针都表示赞赏.
谢谢
我尝试在一个页面中使用JSF 2.0的多个表单.我使用PrimeFaces 3.0M1并尝试使用选项卡和每个选项卡一个表单来构建应用程序.
我有一个如下页面:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:fn="http://java.sun.com/jsp/jstl/functions"
xmlns:p="http://primefaces.prime.com.tr/ui">
<div>
<p:tabView>
<p:tab title="Form1">
<h:form id="form1">
<p:inputText id="txtInput" value="#{bean1.inputText}" />
<p:commandButton title="Submit" value="Submit" actionListener="#{controller1.submitValues}">
</h:form>
</p:tab>
<p:tab title="Form2">
<h:form id="form2">
<p:inputText id="txtInput2" value="#{bean2.inputText}" />
<p:commandButton title="Submit" value="Submit" actionListener="#{controller2.submitValues}">
</h:form>
</p:tab>
</p:tabView>
</div>
</html>
Run Code Online (Sandbox Code Playgroud)
如果我单击选项卡1中的提交按钮,一切都会像被激活的那样工作.但是,如果我单击第二个选项卡上的按钮,则命令将不会在controller2中执行.
这里有什么问题?如果我将button2的执行命令绑定到button1,则控制器2中的命令正确执行,因此我可以排除后备bean中存在问题.
我怎么解决这个问题?
我已经使用PrimeFaces构建了一个应用程序,并希望在apache反向代理后面运行它.
我的目标网址看起来像这样http://myserverurl.org:8080/myapplication/.
我想通过这样的子域访问应用程序http://myapplication.myserverurl.org.
我在apache中配置了一个VirtualHost:
<VirtualHost *:80>
ServerName myapplication.myserverurl.org
ProxyPass / http://myserverurl.org:8080/myapplication/
ProxyPassReverse / http://myserverurl.org:8080/myapplication/
</VirtualHost>
Run Code Online (Sandbox Code Playgroud)
效果不太好.我可以看到JSF页面,但没有应用CSS等.我可以看到第一个请求被正确重定向,但是以下请求(加载jQuery,CSS等)不是.
他们试图访问一个http://myapplication.myserverurl.org/myapplication/faces/javax.faces.resource/primefaces.js?ln=primefaces明显错误的网址.它们不能再次包含/ myapplication / path,因为代理已经重定向到该路径.
我该如何解决这个问题?这是PrimeFaces问题还是我的反向代理配置问题?
我有一个spring应用程序,并希望在运行时根据请求创建一个bean,将其注入另一个类,就像@ProducerCDI一样.
我的bean只是一个简单的POJO:
public class UserDetails {
private String name;
// getter / setter ...
public UserDetails(String name) {
this.name = name;
}
}
Run Code Online (Sandbox Code Playgroud)
我的生产者类看起来像这样:
@Configuration
public class UserFactory {
@Bean
@Scope("request")
public UserDetails createUserDetails() {
// this method should be called on every request
String name = SecurityContextHolder.getContext()
.getAuthentication().getPrincipal(); // get some user details, just an example (I am aware of Principal)
// construct a complex user details object here
return new UserDetails(name)
}
}
Run Code Online (Sandbox Code Playgroud)
这是UserDetails应该注入实例的类: …
我尝试生成动态gwt ui.结果我得到一个像这样的html片段:
<ol>
<li>MyLabel</li>
<li><input type="text"></li>
</ol>
Run Code Online (Sandbox Code Playgroud)
Label应该是GWT标签,输入应该是GWT TextBox.我怎样才能通过GWT实现这一目标?我试过使用HTMLPanel类,但是如何注入
<li>
Run Code Online (Sandbox Code Playgroud)
标签?
我不能使用UIBinder,因为我想动态创建如上所示的片段.
java ×6
c# ×2
jsf-2 ×2
primefaces ×2
spring ×2
apache ×1
gwt ×1
jersey ×1
jsf ×1
junit ×1
rest ×1
spring-boot ×1
subdomain ×1
tdd ×1
unit-testing ×1