我有一个JSF facelets页面,根据他们正在查看的页面显示数据表.当我显示第1页时,我调用view()action方法从数据库获取两个页面的数据,并将其存储为bean的私有成员字段(两个数组).我还调用conversation.start()了view()方法中注入的会话实例.
当用户单击"下一步"按钮(h:commandButton)转到第2页时,我正在执行一个next()方法来更新支持bean以指向数组2,以便打印出其内容.问题是,阵列2不再存在.我不知道为什么我会失去对话范围.有任何想法吗?
//tells the object which page we are on, and thus what data to display.
private int part = 1;
// These arrays are filled with data but conversation scope doesn't
// keep them on the next postback.
private int[] part1 = new int[15], part2 = new int[15];
Run Code Online (Sandbox Code Playgroud) 我正在尝试创建一个令牌验证方法,如果JWT令牌基于签名有效,则返回true.我不认为我真的需要验证令牌中的所有内容,但在调用ValidateToken()之后实际上表示令牌是否有效?一个原则的存在?out引用的标记包含某些值?不确定何时从此方法返回true.
public bool ValidateToken(string tokenString)
{
var validationParameters = new TokenValidationParameters()
{
ValidIssuer = "My Company",
ValidAudience = ApplicationId,
IssuerSigningKey = JsonWebTokenSecretKey
};
SecurityToken token = new JwtSecurityToken();
var tokenHandler = new JwtSecurityTokenHandler();
var principal = tokenHandler.ValidateToken(tokenString, validationParameters, out token);
return principal != null;
}
Run Code Online (Sandbox Code Playgroud) authentication jwt asp.net-web-api asp.net-identity json-web-token
我在SO上讨论了一些其他的例子,讨论了一些奇怪的解决方法,但似乎都没有用,并且它们都是在JSF 2之前的版本中解决的.因此,它可以简单地输出映射的键吗?我试过ui:repeat和c:forEach就像下面没有运气一样:
<c:forEach items="${myBean.myMap.keySet}" var="var">
<h:outputText value="#{var}"/>
</c:forEach>
Run Code Online (Sandbox Code Playgroud) 尝试将现有项目添加回Visual Studio 2015解决方案时,VS会提供以下错误消息.我已经验证我还没有添加对我要添加的项目的引用.我需要删除或清理某个设置或缓存文件吗?
具有相同项目(具有相同全局属性和工具版本的项目)已存在于项目集合中,路径为"D:\ My\Path\MyProject.csproj".要将等效项加载到此项目集合中,请先卸载此项目.
我正在尝试使用GlassFish v3.1.1 Build 12和JSF 2.1设置容器管理的安全性.由于某种原因我一直收到以下异常,我无法登录.
WARNING: WEB9102: Web Login Failed: com.sun.enterprise.security.auth.login.common.LoginException: Login failed: Security Exception
WARNING: Exception
com.sun.enterprise.security.auth.login.common.LoginException: Login failed: Security Exception
at com.sun.enterprise.security.auth.login.LoginContextDriver.doPasswordLogin(LoginContextDriver.java:394)
at com.sun.enterprise.security.auth.login.LoginContextDriver.login(LoginContextDriver.java:240)
at com.sun.enterprise.security.auth.login.LoginContextDriver.login(LoginContextDriver.java:153)
at com.sun.web.security.RealmAdapter.authenticate(RealmAdapter.java:512)
at com.sun.web.security.RealmAdapter.authenticate(RealmAdapter.java:453)
at org.apache.catalina.connector.Request.login(Request.java:1932)
at org.apache.catalina.connector.Request.login(Request.java:1895)
at org.apache.catalina.connector.RequestFacade.login(RequestFacade.java:1146)
at com.perpro.controller.MemberBean.doNavigation(MemberBean.java:354)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.sun.el.parser.AstValue.invoke(AstValue.java:234)
at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:297)
at org.jboss.weld.util.el.ForwardingMethodExpression.invoke(ForwardingMethodExpression.java:43)
at org.jboss.weld.el.WeldMethodExpression.invoke(WeldMethodExpression.java:56)
at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:105)
at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
at javax.faces.component.UICommand.broadcast(UICommand.java:315)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1259)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593)
at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1539)
at …Run Code Online (Sandbox Code Playgroud) 我在Glassfish 3.1.1中配置了一个新的jdbcRealm并启用了FINEST日志记录,当我尝试使用用户名和密码登录时,我得到以下内容.它抱怨我的web应用程序映射到的领域是一个fileRealm,当它真的是一个jdbcRealm.关于为什么Glassfish认为它是fileRealm的任何想法?
FINE: [Web-Security] Setting Policy Context ID: old = null ctxID = PerPro/PerPro
FINE: [Web-Security] hasUserDataPermission perm: (javax.security.jacc.WebUserDataPermission /index.jsf POST)
FINE: [Web-Security] hasUserDataPermission isGranted: true
FINEST: Processing login with credentials of type: class com.sun.enterprise.security.auth.login.common.PasswordCredential
FINE: Logging in user [admin] into realm: file using JAAS module: fileRealm
FINE: Login module initialized: class com.sun.enterprise.security.auth.login.FileLoginModule
FINE: No such user: [admin]
FINE: JAAS authentication aborted.
FINEST: doPasswordLogin fails
javax.security.auth.login.LoginException: Failed file login for admin.
at com.sun.enterprise.security.auth.login.FileLoginModule.authenticate(FileLoginModule.java:84)
at com.sun.enterprise.security.auth.login.PasswordLoginModule.authenticateUser(PasswordLoginModule.java:117)
at com.sun.appserv.security.AppservPasswordLoginModule.login(AppservPasswordLoginModule.java:148)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) …Run Code Online (Sandbox Code Playgroud) 当您查看Twitter等社交网站上的个人资料图片时,他们会存储以下图像文件:
http://a1.twimg.com/profile_images/1082228637/a-smile_twitter_100.jpg
Run Code Online (Sandbox Code Playgroud)
或者甚至在20110912这样的路径中的某个地方.我能想到的唯一直接好处就是阻止僵尸程序以线性方式通过并下载存储中的所有文件.我错过了其他任何好处吗?随机化它的最佳方法是什么?
我正在使用Amazon S3,所以我将有一个子域服务我所有的静态内容.我的计划是在我的数据库中存储一个整数ID,然后只使用id连接URL以形成位置.
我在JSF 2中使用Primefaces 3来制作搜索框.我需要向控件添加一个非标准属性(x-webkit-speech),这样你就会有这样的东西......
<p:autoComplete x-webkit-speech="x-webkit-speech" ... />
Run Code Online (Sandbox Code Playgroud)
由于此属性不是autoComplete控件的一部分,因此JSF给出了500错误.但是当我删除它时,页面渲染得很好.通常,如何在JSF标记上指定传递属性,以便忽略它们?
我在一个不同的问题中询问了传递属性,发现我可以为<p:autocomplete>组件创建一个自定义渲染器,但问题是我的自定义渲染器将用于我项目中的每个p:autocomplete(站点范围).因此,我选择创建一个自定义组件,该组件扩展org.primefaces.component.autocomplete.AutoComplete并向文本框添加必要的属性.
我最初的想法是添加一个构造函数,但它似乎不起作用,因为此时属性map为null:
@FacesComponent("com.mycomponents.SiteSearch")
public class SiteSearch extends AutoComplete {
public SiteSearch() {
Map<String,Object> attrs = getAttributes();
attrs.put("x-webkit-speech", null);
attrs.put("x-webkit-grammer", "builtin:search");
attrs.put("onwebkitspeechchange", "this.form.submit();");
attrs.put("placeholder", "Enter a Search Term");
}
}
Run Code Online (Sandbox Code Playgroud)
我的另一个想法是将此自定义组件留空(空类),然后指定一个自定义渲染器,用于扩展org.primefaces.component.autocomplete.AutoCompleteRenderer和修改那里的属性.
毕竟说完了之后,我只需要一种方法将这些属性与这一个文本框分开,这样只需在p:autoComplete上放一个自定义渲染器就行不通了(除非我可以使用renderType =属性这个)电话号码:自动完成?).
我有以下DatabaseFixture内容对我迄今为止创建的所有测试都有效.我使用这个fixture进行集成测试,所以我可以在数据库模式结构上做出真正的断言.
public class DatabaseFixture : IDisposable
{
public IDbConnection Connection => _connection.Value;
private readonly Lazy<IDbConnection> _connection;
public DatabaseFixture()
{
var environment = Environment.GetEnvironmentVariable("ASPNET_ENVIRONMENT") ?? "Development";
var configuration = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("AppSettings.json", optional: false, reloadOnChange: true)
.AddJsonFile($"AppSettings.{environment}.json", optional: true, reloadOnChange: true)
.Build();
_connection = new Lazy<IDbConnection>(() =>
{
var connection = new MySqlConnection(configuration["ConnectionStrings:MyDatabase"]);
connection.Open();
return connection;
});
}
public void Dispose()
{
Connection?.Dispose();
}
}
[CollectionDefinition("Database Connection Required")]
public class DatabaseConnectionFixtureCollection : ICollectionFixture<DatabaseFixture>
{
}
Run Code Online (Sandbox Code Playgroud)
我面临的问题是我现在需要调用一个测试方法,就像MyDataIsAccurate(...)从数据库中的表中的每个记录一样.xUnit提供的 …