我需要本地化下拉列表。 我已尝试使用1和2,但仍然无效。 所以这是当前系统中的代码示例
Enum中的主数据
CREATE TRIGGER [dbo].[TrigInsertToMeasurements]
ON [dbo].[MeasurementsTemp]
FOR INSERT
AS
BEGIN
SET NOCOUNT ON;
SET XACT_ABORT ON;
-- Dichiaro le variaibili --
DECLARE
@TimeStamp datetime,
@MachineType char(10),
@MachineModel char(10),
@MachineNumber int,
@Part char(10),
@PartNumber int,
@ValueKind char(10),
@Value float,
@ID int
-- Assegno i valori --
SELECT
@TimeStamp = TimeStamp,
@MachineType = MachineType,
@MachineModel = MachineModel,
@MachineNumber = MachineNumber,
@Part = Part,
@PartNumber = PartNumber,
@ValueKind = ValueKind,
@Value = Value
FROM
inserted
SELECT @ID=ID FROM [dbo].[Hashtable]
WHERE
@MachineType = [MachineType] AND
@MachineModel = [MachineModel] AND
@MachineNumber = MachineNumber AND
@Part = Part AND
@PartNumber = PartNumber AND
@ValueKind = ValueKind
IF count(@ID) = count(@TimeStamp)
BEGIN
INSERT INTO [dbo].[Measurements] ([TimeStamp], [ID], [Value] ) VALUES (@TimeStamp, @ID, @Value)
END
ELSE BEGIN
BEGIN
IF NOT EXISTS (SELECT [ID] FROM [dbo].[Hashtable] WHERE
@MachineType = [MachineType] AND
@MachineModel = [MachineModel] AND
@MachineNumber = MachineNumber AND
@Part = Part AND
@PartNumber = PartNumber AND
@ValueKind = ValueKind)
BEGIN
INSERT INTO [dbo].[Hashtable] (MachineType, MachineModel, MachineNumber, Part, PartNumber, ValueKind)
VALUES (@MachineType, @MachineModel, @MachineNumber, @Part, @PartNumber, @ValueKind)
END
END
SELECT @ID=ID FROM [dbo].[Hashtable]
WHERE
@MachineType = MachineType AND
@MachineModel = MachineModel AND
@MachineNumber = MachineNumber AND
@Part = Part AND
@PartNumber = PartNumber AND
@ValueKind = ValueKind
INSERT INTO [dbo].[Measurements] ([TimeStamp], [ID], [Value] ) VALUES (@TimeStamp, @ID, @Value)
END
END
GO
ALTER TABLE [dbo].[MeasurementsTemp] ENABLE TRIGGER [TrigInsertToMeasurements]
GO
在Action类
中 public class EnumConstant {
public enum ApplicationUserType {
DEPARTMENT("Department"), CITIZEN("Citizen"), OTHER("Other");
private String displayName;
private ApplicationUserType(String name) {
this.displayName = name;
}
public String getDisplayName() {
return displayName;
}
public void setDisplayName(String displayName) {
this.displayName = displayName;
}
private static final Map<String, ApplicationUserType> LOOKUP =
new LinkedHashMap<String, ApplicationUserType>();
private static final Map<String, ApplicationUserType> CODE_LOOKUP =
new LinkedHashMap<String, ApplicationUserType>();
static {
for (ApplicationUserType applicationUserType : EnumSet.allOf(ApplicationUserType.class)) {
LOOKUP.put(applicationUserType.getDisplayName(), applicationUserType);
CODE_LOOKUP.put(applicationUserType.toString(), applicationUserType);
}
}
public static ApplicationUserType fromCode(String code) {
return LOOKUP.get(code);
}
public static ApplicationUserType fromDisplayName(String displayName) {
return CODE_LOOKUP.get(displayName);
}
public static Map<String, ApplicationUserType> getApplicationUserTypeMap() {
return LOOKUP;
}
}
}
Jsp文件
@Namespace("/")
public class ApplicationAction extends ActionSupport implements SessionAware {
private Map<String, ApplicationUserType> applicationUserTypeMap;
@Action(value = "showApplication", results = {
@Result(name = "success", location = "/WEB-INF/jsp/view/application.jsp"),
@Result(name = "error", location = "/WEB-INF/jsp/view/home.jsp")})
public String execute() {
populateMasterData();
return SUCCESS;
}
public void populateMasterData() {
try {
applicationUserTypeMap = EnumConstant.ApplicationUserType.getApplicationUserTypeMap();
} catch (Exception e) {
e.printStackTrace();
}
}
public Map<String, ApplicationUserType> getApplicationUserTypeMap() {
return applicationUserTypeMap;
}
public void setApplicationUserTypeMap(Map<String, ApplicationUserType> applicationUserTypeMap) {
this.applicationUserTypeMap = applicationUserTypeMap;
}
}
应用程序中的大多数地方都使用这个:select和enum来生成下拉列表。因此,我无法使用
<s:select cssClass="form-control"
list="applicationUserTypeMap" listValue="value.displayName" listKey="value"
name="applicationVO.applicationUserType" required="false" id="applicationUserType"/>
最终目标是将此部门,公民和其他选项本地化为另一种语言。