我正在使用primefaces fileUpload组件,然后检查FileUploadEvent.getFile,但没有找到可靠获取扩展名的方法。有任何想法吗?
下面的代码创建了一个Spring Authentication对象,该对象与我查看SecurityContext context = SecurityContextHolder.getContext()时的role_user关联; 在最后它确实有ROLE_USER和UserDetails的主体,因此不知何故它没有与我的HttpSession相关联.有任何想法吗?我的例外也在下面
public String login(){
if(signUpDetailBean.getEmail() != null){
sers currentUser = userManager.getUser(signUpDetailBean.getEmail());
authenticateUserAndSetSession(currentUser, (HttpServletRequest) FacesUtils.getExternalContext().getRequest());
clearForm();
return "/registered/home.html";
}else{
clearForm();
return "/auth/login.html";
}
}
private void authenticateUserAndSetSession(Users user, HttpServletRequest request)
{
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(
user.getUsername(), user.getPassword());
// generate session if one doesn't exist
request.getSession();
token.setDetails(new WebAuthenticationDetails(request));
Authentication authenticatedUser = authenticationManager.authenticate(token);
SecurityContextHolder.getContext().setAuthentication(authenticatedUser);
SecurityContext context = SecurityContextHolder.getContext();
}
Run Code Online (Sandbox Code Playgroud)
19:11:07,599 DEBUG AntPathRequestMatcher:72 - Checking match of request : '/registered/home.html'; against '/javax.faces.resource/**'
19:11:07,600 DEBUG AntPathRequestMatcher:72 - Checking match …Run Code Online (Sandbox Code Playgroud) 我想setPropertyActionListener在我的commandLink中嵌套多个,但只有一个可以工作.你是怎么做到的?此命令链接设置属性,然后打开一个对话框,以便它基本上初始化对话框.
这是如何完成的?
<p:commandLink update=":dreamWebSearchFrm" value="#{bundle['dreamModify.search.link.TEXT']}" oncomplete="webSearchDlg.show()">
<f:setPropertyActionListener value="false" target="#{dreamSearchBean.shouldRender}"/>
<f:setPropertyActionListener value="true" target="#{dreamSearchBean.shouldRender1}"/>
</p:commandLink>
Run Code Online (Sandbox Code Playgroud) 我需要在我的spring security 3.0.5 Web应用程序中对用户进行解除身份验证(终止他们的会话),然后将重定向发送到另一个站点以通知他们注销.这在春天是否可行?如果是这样,执行这些任务的一般方法是什么?谢谢!
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.logout.SimpleUrlLogoutSuccessHandler;
import com.dc.api.model.Users;
public class DCSimpleUrlLogoutSuccessHandler extends SimpleUrlLogoutSuccessHandler{
public void onLogoutSuccess(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
Authentication authentication)
throws java.io.IOException,
javax.servlet.ServletException{
Users user=null;
Object principal = authentication.getPrincipal();
if (principal instanceof Users) {
user = (Users) principal;
if(user.getType().equals(TEST)){
response.sendRedirect("LogoutServlet");
}
}
response.sendRedirect("login.html");
}
Run Code Online (Sandbox Code Playgroud)
}
java.lang.IllegalStateException
org.apache.catalina.connector.ResponseFacade.sendRedirect(ResponseFacade.java:463)
javax.servlet.http.HttpServletResponseWrapper.sendRedirect(HttpServletResponseWrapper.java:138)
org.springframework.security.web.context.SaveContextOnUpdateOrErrorResponseWrapper.sendRedirect(SaveContextOnUpdateOrErrorResponseWrapper.java:74)
com.dc.api.service.impl.DCSimpleUrlLogoutSuccessHandler.onLogoutSuccess(DCSimpleUrlLogoutSuccessHandler.java:24)
org.springframework.security.web.authentication.logout.LogoutFilter.doFilter(LogoutFilter.java:100)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
org.springframework.security.web.context.SecurityContextPersistenceFilter.doFilter(SecurityContextPersistenceFilter.java:79)
org.springframework.security.web.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:380)
org.springframework.security.web.FilterChainProxy.doFilter(FilterChainProxy.java:169)
org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:237)
org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
Run Code Online (Sandbox Code Playgroud) 我不确定这是一个bug还是只是没有实现的东西,但是我无法更新dataGrids页面属性以将分页重置为第1页.我已将它绑定到我的bean中的表达式并更新它通过ajax更新,但单击我的按钮时它不会更新.分页器将保留在选定页面上,不会通过ajax请求重置.我正在尝试重置它.dreamSearchBean的setCurrentPage会被调用并被传递1,但它会保留在上次选择的任何页面上
<h:form id="dreamWebSearchFrm">
<p:commandButton styleClass="form-btn1" value="#{bundle['dreamSearch.search.button.TEXT']}" onclick="trackingDreamSearch()"
actionListener="#{dreamSearch.search}" update=":dreamWebSearchFrm:resultsPnl">
<f:setPropertyActionListener value="1" target="#{dreamSearchBean.currentPage}"/>
</p:commandButton>
<p:panel id="resultsPnl">
<div class="data-grid-wrap">
<h:outputFormat escape="false" value="#{bundle['dreamSearch.imageResults.TEXT']}" rendered="#{dreamSearchBean.shouldRender}" >
<f:param value="#{dreamSearchBean.searchText}" />
</h:outputFormat>
<p:dataGrid var="dream" value="#{dreamSearchBean.dreams}" rendered="#{dreamSearchBean.shouldRender}" page="#{dreamSearchBean.currentPage}" pageLinks="3" columns="4" rows="4" paginator="true" effect="true"
styleClass="ui-header-visibility"
paginatorTemplate="{FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}"
paginatorPosition="bottom">
<p:column>
<h:panelGrid columns="1">
<p:commandLink onclick="webSearchDlg.hide();dreamEditDlg.show();" update=":dreamEditFrm:display">
<f:setPropertyActionListener value="#{dream}" target="#{dreamModifyBean.selectedDream}"/>
<p:graphicImage value="#{dream.imageThumb}" width="125" height="100"></p:graphicImage>
</p:commandLink>
</h:panelGrid>
</p:column>
</p:dataGrid>
</div>
</p:panel>
</h:form>
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用XPath来解析XML字符串,但我只返回空值.有没有人知道下面的代码我可能会出错?
public static void main(String[] args) {
String content = "<imagesXML><Images><Image><ImageUID Scope='Public' Type='Guid' Value='{7f2535d0-9a41-4997-9694-0a4de569e6d9}'/><CorbisID Scope='Public' Type='String' Value='42-15534232'/><Title Scope='Public' Type='String' Value='Animal'/><CreditLine Scope='Public' Type='String' Value='© Robert Llewellyn/Corbis'/><IsRoyaltyFree Scope='Public' Type='Boolean' Value='False'/><AspectRatio Scope='Public' Type='String' Value='1.500000'/><URL128 Scope='Public' Type='String' Value='http://cachens.corbis.com/CorbisImage/thumb/15/53/42/15534232/42-15534232.jpg'/></Image></Images></imagesXML>";
InputSource source = new InputSource(new StringReader(content));
XPath xPath = XPathFactory.newInstance().newXPath();
NodeList list = null;
try {
list = (NodeList) xPath.evaluate("//URL128[@Value]", source,
XPathConstants.NODESET);
} catch (Exception ex) {
System.out.println(ex.getMessage());
}
for (int i = 0; i < list.getLength(); i++) {
System.out.println(list.item(i));
}
}
Run Code Online (Sandbox Code Playgroud)
从System.out的输出是"值= [URL128:空]",但它应该是我试图提取的网址:http://cachens.corbis.com/CorbisImage/thumb/15/53/42/15534232/42-15534232.jpg. …
当移动应用程序页面方向从横向更改为纵向时,更改css文件的最佳方法是什么,反之亦然.我只需要支持Android和iPhone.媒体查询似乎不是最干净的方式,其他任何想法?
我有一个SWIG接口文件,它将一些C函数(通过JNI)公开给我的Java应用程序,这些C结构用作C函数的输入(通过SWIG/JNI).SWIG将结构生成为Java类,但我不确定如何设置结构属性,因为setter采用SWIG生成的类型.我需要在将结构属性作为输入传递到我的Java类的C函数之前设置它们.example_location_id_t_是我需要传递的类,但是setter用于Id并Phy_idx采用以下SWIG类型.如何填充SWIGTYPE_p_unsigned_char,并SWIGTYPE_p_uint32_t让我可以设置Id和Phy_idx该属性SWIGTYPE_p_uint32_t类?
setId(SWIGTYPE_p_unsigned_char value) 和 setPhy_idx(SWIGTYPE_p_uint32_t value)
package com.test.jni;
public class SWIGTYPE_p_unsigned_char {
private long swigCPtr;
protected SWIGTYPE_p_unsigned_char(long cPtr, boolean futureUse) {
swigCPtr = cPtr;
}
protected SWIGTYPE_p_unsigned_char() {
swigCPtr = 0;
}
protected static long getCPtr(SWIGTYPE_p_unsigned_char obj) {
return (obj == null) ? 0 : obj.swigCPtr;
}
}
package com.test.jni;
public class SWIGTYPE_p_uint32_t {
private long swigCPtr;
protected SWIGTYPE_p_uint32_t(long cPtr, boolean futureUse) {
swigCPtr = cPtr; …Run Code Online (Sandbox Code Playgroud) 我正在尝试从strings.xml文件中为TextView android:text属性分配以下字符串.我无法将链接显示为可点击的超链接.有什么建议?我尝试过以下技巧.
<string name="no_device_body">click following link: <![CDATA[<a href="http://cnn.com">link1</a>]]>
</string>
<string name="no_device_body">click following link: http://cnn.com">
</string>
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用GMT解析表示日期的字符串,但它会在我的PC上(太平洋)打印出我的时区.当我运行以下时,我得到以下输出.关于如何解析解析并返回GMT日期的任何想法?如果你看下面我正在使用format.setTimeZone设置时区(TimeZone.getTimeZone("GMT")); 但它没有产生预期的结果.
以下代码输出:
星期一10月29日05:57:00 PDT 2012
package javaapplication1;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.TimeZone;
public class JavaApplication1 {
public static void main(String[] args) throws ParseException {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
format.setTimeZone(TimeZone.getTimeZone("GMT"));
System.out.println(format.parse("2012-10-29T12:57:00-0000"));
}
}
Run Code Online (Sandbox Code Playgroud)