我弹簧安全登录表单我们有以下表格
<form name='f' action='/j_spring_security_check' method='POST'>
<table>
<tr><td>User:</td><td><input type='text' name='j_username' value=''></td></tr>
<tr><td>Password:</td><td><input type='password' name='j_password'/></td></tr>
<tr><td colspan='2'><input name="submit" type="submit"/></td></tr>
<tr><td colspan='2'><input name="reset" type="reset"/></td></tr>
</table>
</form>
Run Code Online (Sandbox Code Playgroud)
我知道如何修改此表单上的action属性(使用 login-processing-url="/login")我的问题是如何更改j_username和j_password标签名称,是用户名和密码?
我有以下JSF 2.1页面
<h:selectOneRadio value="#{userBean.newUser}">
<f:selectItem itemValue="0" itemLabel="new User" />
<f:selectItem itemValue="1" itemLabel="existing User" />
</h:selectOneRadio>
<br />
<h:inputText value="#{userBean.customerId}" id="customerId" />
<h:message for="customerid" />
<br />
<h:inputText value="#{userBean.firstName}" id="firstName" />
<h:message for="fisrtName" />
<br />
<h:inputText value="#{userBean.lastName}" id="lastName" />
<h:message for="lastName" />
<br />
<h:commandButton value="Submit" action="#{userBean.login}" />
Run Code Online (Sandbox Code Playgroud)
这是我的豆子:
public class UserBean {
private String customerId;
private String newUser= "0";
private String firstName;
private String lastName;
// Getters and seeters ommited.
}
Run Code Online (Sandbox Code Playgroud)
我需要通过以下方式验证此表单:
如果选择"新用户"单选按钮,则应验证所有表单输入.如果选择"现有用户",我只需要验证客户ID.
我尝试了Hibernate验证,我还通过实现javax.faces.validator.Validator接口尝试了自定义验证器.
我能以某种方式实现这样的功能吗?
我正在尝试编写一个非常简单的程序,它将模仿简单的DeadLock,其中线程A等待由线程B锁定的资源A,线程B等待由线程A锁定的资源B.
这是我的代码:
//it will be my Shared resource
public class Account {
private float amount;
public void debit(double amount){
this.amount-=amount;
}
public void credit(double amount){
this.amount+=amount;
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的runnable,它在上面的资源上执行Operation:
public class BankTransaction implements Runnable {
Account fromAccount,toAccount;
float ammount;
public BankTransaction(Account fromAccount, Account toAccount,float ammount){
this.fromAccount = fromAccount;
this.toAccount = toAccount;
this.ammount = ammount;
}
private void transferMoney(){
synchronized(fromAccount){
synchronized(toAccount){
fromAccount.debit(ammount);
toAccount.credit(ammount);
try {
Thread.sleep(500);
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println("Current Transaction Completed!!!");
}
}
}
@Override
public …Run Code Online (Sandbox Code Playgroud) 我需要创建Job,它将:
这个cron表达式有效吗?
Date start = 12/20/2012;
Date endDate = 12/31/2017;
SimpleTrigger trigger = newTrigger()
.withIdentity("trigger3", "group1")
.startAt(startDate)
.withSchedule(cronSchedule("* * 17 0 0/2 *,SUN,MON").build())
.endAt(endDate)
.build;
Run Code Online (Sandbox Code Playgroud)
请指教.
我正在尝试使用soap标头发送SOAP请求,如下所示:
<SOAP-ENV:Header>
<Security xmlns="http://www.xxx.org/xxx/2003/05">
<UsernameToken><Username>yyyy</Username><Password>xxx</Password>
</UsernameToken></Security></SOAP-ENV:Header>
Run Code Online (Sandbox Code Playgroud)
为了做到这一点,我正在使用添加标题元素 SoapActionCallback
SoapActionCallback actionCallBack = new SoapActionCallback("https://aaa.com/bbb.asmx") {
public void doWithMessage(WebServiceMessage msg) {
SoapMessage smsg = (SoapMessage) msg;
smsg.setSoapAction("http://www.xxx.org/yyy/2003/05/SessionCreate");
SoapHeaderElement security = smsg.getSoapHeader().addHeaderElement(new QName("http://www.xxx.org/yyy", "Security"));
security.setText("<UsernameToken><Username>yyyy</Username><Password>xxx</Password></UsernameToken>");
}
};
Run Code Online (Sandbox Code Playgroud)
我的问题是soap标题看起来像这样
<SOAP-ENV:Header><Security xmlns="http://www.xxx.org/yyy/2003/05"><UsernameToken><Username>yyyyy</Username><Password>xxxx</Password></UsernameToken></Security></SOAP-ENV:Header>
Run Code Online (Sandbox Code Playgroud)
结果我的请求失败了:
如何正确添加此消息?
在我的测试场景中,我正在轮询用户会话以获取可能的响应。由于产品行为,在收到响应之前多次收到 503 是正常的,这就是我最多重试 5 次的原因。
tryMax(5){
exec(http("Poll user")
.get("/something.html")
.queryParamMap(Map("NC" -> "true", "data" -> "true", "v" -> "1"))
.check(
status.is(200))
)}
Run Code Online (Sandbox Code Playgroud)
现在'当我查看统计数据时,我看到 4 个失败的请求:
[--------------------------------------------------------------------------] 0%
waiting: 0 / active: 80 / done:0
---- Requests ------------------------------------------------------------------
> Global (OK=1771 KO=4 )
> Form Login (OK=80 KO=0 )
> ********************** (OK=80 KO=0 )
> Agent Base (OK=80 KO=0 )
> Login (OK=80 KO=0 )
> Set availability to Online (OK=80 KO=0 )
> Poll session (OK=1291 KO=4 )
---- Errors -------------------------------------------------------------------- …Run Code Online (Sandbox Code Playgroud) 我有以下课程:
public class Student {
private Long id ;
private String firstName;
private String lastName;
private Set<Enrollment> enroll = new HashSet<Enrollment>();
//Setters and getters
}
public class Enrollment {
private Student student;
private Course course;
Long enrollId;
//Setters and Getters
}
Run Code Online (Sandbox Code Playgroud)
我有Struts2控制器,我想只返回Class Student的Serialized实例.
@ParentPackage("json-default")
public class JsonAction extends ActionSupport{
private Student student;
@Autowired
DbService dbService;
public String populate(){
return "populate";
}
@Action(value="/getJson", results = {
@Result(name="success", type="json")})
public String test(){
student = dbService.getSudent(new Long(1));
return "success";
}
@JSON(name="student")
public Student …Run Code Online (Sandbox Code Playgroud) 我有这种@OneToOne Hibernate relationShip
public class Address implements Serializable {
private String id;
private String city;
private String country;
//setter getters ommitted
}
public class Student implements Serializable {
private String id;
private String firstName;
private String lastName;
private Address address;
}
Run Code Online (Sandbox Code Playgroud)
地址项目映射为LAZY.
现在我想使用获取用户及其地址
session.load(Student.class,id);
Run Code Online (Sandbox Code Playgroud)
在我的daoService中.
然后我从Spring MVC控制器返回JSON:
@RequestMapping(value="/getStudent.do",method=RequestMethod.POST)
@ResponseBody
public Student getStudent(@RequestParam("studentId") String id){
Student student = daoService.getStudent(id);
return student;
}
Run Code Online (Sandbox Code Playgroud)
不幸的是,由于懒惰的clasees它没有工作,我失败了:
org.codehaus.jackson.map.JsonMappingException: No serializer found for class org.hibernate.proxy.pojo.javassist.JavassistLazyInitializer and no properties discovered to create BeanSerializer (to avoid exception, disable …Run Code Online (Sandbox Code Playgroud) 我有以下课程:
package x.y.z;
public class MyClass{
public void someMethod(SomeObject object){
//do somethinng
}
public void {
//do somethinng
}
}
Run Code Online (Sandbox Code Playgroud)
现在我想@PointCut只设置方法someMethod(SomeObject object, int param1)
我该怎么做?
更新我正在尝试
@Pointcut("execution(x.y.z.MyClass.someMethod(x.y.z.SomeObject))") but I'm getting not well formed pointcut exception.
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用递归来解决迷宫问题.它被宣布了Cell [][] maze.
public class Cell {
private Wall left;
private Wall right;
private Wall up;
private Wall down;
private boolean end;
// Setters and getters not shown
}
Run Code Online (Sandbox Code Playgroud)
如果Wall单元格的某一侧没有,那么它有值null,否则它指的是一个Wall对象.Wall参考是一致的:与单壁相邻的两个单元都用适当的字段表示它.如果缺少墙,则两个相邻的单元都具有相应的null条目.这是搜索:
public boolean solveMaze(Cell[][] maze, int i, int j) {
if (maze[i][j].isEnd()){
System.out.println(maze[i][j].toString());
return true;
}
if (maze[i][j].getDown() == null) {
return solveMaze(maze, i, j + 1);
}
if (maze[i][j].getUp() == null) {
return solveMaze(maze, i, j - 1) …Run Code Online (Sandbox Code Playgroud) java ×6
java-ee ×5
spring ×3
hibernate ×2
json ×2
algorithm ×1
aop ×1
concurrency ×1
cron ×1
deadlock ×1
forms ×1
gatling ×1
jsf ×1
jsf-2 ×1
lazy-loading ×1
load ×1
maze ×1
performance ×1
richfaces ×1
scala ×1
soap ×1
spring-aop ×1
spring-mvc ×1
spring-ws ×1
struts2 ×1