我已经为我的项目启用了 Checkstyle。它在方法参数上显示黄色标记并请求将其设置为final
。为什么?什么目的?如果不指定会出现什么问题?
我的Action类有以下方法,
1.add
2.edit
3.loadEdit
4.remove
5.list
6.execute
Run Code Online (Sandbox Code Playgroud)
在这个我需要应用验证添加和编辑..如何需要在struts.xml.I配置,然后,
<action name="editComment" method="edit"
class="com.mmm.ehspreg2.web.action.product.CommentAction">
<result name="success">/jsp/propertyManager/loadList.jsp</result>
</action>
<action name="removeComment" method="remove"
class="com.mmm.ehspreg2.web.action.product.CommentAction">
<interceptor-ref name="validation">
<param name="excludeMethods">remove</param>
</interceptor-ref>
<result type="tiles">listComment</result>
<result type="tiles" name="input">listComment</result>
</action>
Run Code Online (Sandbox Code Playgroud)
当我像这样配置它时,不会调用remove action方法.我不明白这个问题.请协助.
我试图检查List是否包含特定元素或不使用<s:if>
标记中的Struts 2 ?
<display:table class="noheader-border" id="data" name="lstAttendance" sort="list"
uid="row" htmlId="sources" export="false">
<display:column style="width:150px">
<s:property value="%{#attr.row.worker.workerName}" />
</display:column>
<display:column style="width:10px;weight:bold;">:</display:column>
<s:if test="lstSalaryDefinedWorkerId.contains(%{#attr.row.workerId})">
...
</s:if>
...
Run Code Online (Sandbox Code Playgroud) 我试图在显示标记标题键中使用应用程序资源属性.什么都没显示.请帮忙继续.我正在使用struts2.
如何克隆标准对象?
我创建了Criteria对象来连接多个表并应用多个限制.然后我需要基于所应用的限制的记录总数.然后我需要应用分页细节(通过设置maxList)并且必须检索对象列表.
Criteria criteria = session.createCriteria(Property.class, "property")
.createAlias("property.propertyType", "type").createAlias(
"property.propertyConcern", "propertyConcern",
CriteriaSpecification.LEFT_JOIN).createAlias(
"propertyConcern.concern", "concern",
CriteriaSpecification.LEFT_JOIN).setResultTransformer(
CriteriaSpecification.DISTINCT_ROOT_ENTITY);
criteria = addMultipleSeachCriteria(criteria, condition);
criteria.setFirstResult(
pageCriteria.getFirstRecordOfCurrentPage())
.setMaxResults(pageCriteria.getRecordsPerPage());
criteria.addOrder(pageCriteria.isSortDescending() ? Order
.desc(pageCriteria.getSortBy()) : Order
.asc(pageCriteria.getSortBy()));
Run Code Online (Sandbox Code Playgroud)
当我运行这个时,我得到了我预期的结果.但我需要获取应用限制的记录数量而不应用order by和setmaxResults.我如何实现?我无法克隆条件对象也..
我在 Hibernate 属性公式字段中遇到问题 - 我无法组合两个表列。
shift_id
列所属的父表job_card
和duration
列所属的子表job_card_idle_time
。但它认为两列都属于job_card
.
<property
name="utilization"
formula="(count(shift_id)*340)-sum(duration)/(count(shift_id)*340)"
generated="never"
insert="false"
update="false"
type="float">
</property>
Run Code Online (Sandbox Code Playgroud)
结果查询:
select (count(this_.shift_id)*340)-sum(**this_.duration**) /(count(this_.shift_id)*340) as y0_,
this_.JOB_CARD_DATE as y1_
from job_card this_
left outer join job_card_idle_time ir1_ on this_.JOB_CARD_ID=ir1_.JOB_CARD_ID
where this_.JOB_CARD_DATE between ? and ?
group by this_.JOB_CARD_DATE
order by this_.JOB_CARD_DATE desc
Run Code Online (Sandbox Code Playgroud)
我想要这样。
select (count(this_.shift_id)*340)-sum(**ir1_.duration**)
/(count(this_.shift_id)*340) as y0_,
this_.JOB_CARD_DATE as y1_
from job_card this_
left outer join job_card_idle_time ir1_ on this_.JOB_CARD_ID=ir1_.JOB_CARD_ID
where this_.JOB_CARD_DATE between ? and ? …
Run Code Online (Sandbox Code Playgroud) 如何在ajax中调用Struts2 Action方法.现在我工作调用servlet.is有可能吗?如果有的话请分享.
我正在为我的应用程序使用会话语言环境解析器.我在下拉列表中显示语言.如果用户选择任何一种语言,则重新填充该语言的所有值.
<property name="interceptors">
<list>
<ref bean="localeChangeInterceptor" />
</list>
</property>
<bean id="localeChangeInterceptor"
class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
<property name="paramName" value="languageCode" />
</bean>
<bean id="localeResolver"
class="org.springframework.web.servlet.i18n.SessionLocaleResolver" />
Run Code Online (Sandbox Code Playgroud)
但它并没有从会议中读到它.始终从浏览器设置中考虑默认语言.请帮忙.
我是struts 2的新手.我在使用list属性填充Select标签时遇到问题.这些值是从动作类提供的.请为此方案提供示例sode.
我的动作课
public class TripDetailsAdd extends ActionSupport {
@Override
public String execute() throws Exception {
return SUCCESS;
}
public String populate() {
VehicleDAO vehicleDAO = new VehicleDAO();
this.lstVehicles.addAll(vehicleDAO.getAllVehicles());
return "populate";
}
private String vehicleId;
private Collection lstVehicles = new ArrayList<VehiclesVO>();
}
Run Code Online (Sandbox Code Playgroud)
Jsp页面内容:
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="sform" uri="/struts-dojo-tags"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@page import="com.vms.business.dao.VehicleDAO"%>
<%@page import="java.util.Collection"%><html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Trip Details</title>
</head>
<body>
<s:form action="tripDetailsAdd" …
Run Code Online (Sandbox Code Playgroud) 我是这个框架的新手.在我的页面中,我有一个下拉列表和一个文本框.如果出现任何错误,则不再提供丢弃.如何解决这个问题.
struts.xml中:
<action name="*DropDown"
class="com.mmm.ehspreg2.web.action.DropdownListAction" method="{1}" />
<action name="addComment" method="add"
class="com.mmm.ehspreg2.web.action.product.CommentAction">
<result name="input" type="tiles">addComment</result>
<result name="error" type="tiles">addComment</result>
<result name="success" type="tiles">reloadList</result>
</action>
Run Code Online (Sandbox Code Playgroud)
页:
<s:form action="addComment" method="POST">
<s:action name="getDivisionsDropDown" id="actFetchDivisions" executeResult="true"></s:action>
<s:action name="getPropretyTypesDropDown" id="actFetchPropretyTypes" executeResult="true" ></s:action>
<table cellspacing="0" cellpadding="3" width="100%" border="0">
<tr>
<td class="error"><s:actionerror /><s:actionmessage /> <s:fielderror></s:fielderror></td>
</tr>
<tr>
<td class="bdyRecords"><s:label>
<s:text name="common.division" />
</s:label></td>
<td class="bdyRecords" style="width: 1px">:</td>
<td class="bdyRecords"><s:if
test="#actFetchDivisions.lstEntities.size()>0">
<s:select cssClass="drop" list="#actFetchDivisions.lstEntities"
cssStyle="width:200px" tooltip="divisionName"
id="select_division" listKey="id" name="comment.divisionId"
listValue="value"></s:select>
</s:if></td>
</tr>
<tr>
<td class="bdyRecords"><s:label>
<s:text name="common.propertytype" />
</s:label></td>
<td class="bdyRecords" …
Run Code Online (Sandbox Code Playgroud) struts2 ×6
java ×4
hibernate ×2
ajax ×1
checkstyle ×1
displaytag ×1
jsp ×1
ognl ×1
select ×1
spring ×1
spring-mvc ×1
tags ×1