public class Controller {
Employee nameFile = new Employee();
@FXML
private TextField firstNameField;
@FXML
private TextField lastNameField;
public void getinfo() throws FileNotFoundException, IOException {
String filename = "file.abc";
nameFile.setFirstNameField(firstNameField.getText());
nameFile.setLastNameField(lastNameField.getText());
// Serialization
try
{
//Saving of object in a file
File employeeName = new File("file.abc");
FileOutputStream file = new FileOutputStream(employeeName);
ObjectOutputStream out = new ObjectOutputStream(file);
out.writeObject(nameFile);
out.close();
file.close();
Alert alert = new Alert(Alert.AlertType.INFORMATION);
alert.setTitle("Information Saved");
alert.setHeaderText(null);
alert.setContentText("Your Information has been saved!");
alert.showAndWait();
}
catch(IOException ex)
{
System.out.println("IOException is caught");
}
}
public void setDataField() {
try {
// Reading the object from a file
FileInputStream file = new FileInputStream("file.abc");
ObjectInputStream in = new ObjectInputStream(file);
// Method for deserialization of object
nameFile = (Employee) in.readObject();
/*How to I pull that data to the textfield firstnamefield and lastnamefield this method is invoked */
in.close();
file.close();
} catch (FileNotFoundException ex) {
System.out.println("FileNotFoundException is caught");
} catch (IOException ex) {
System.out.println("IOException is caught");
}
}
}
我的控制器是这样的
Route::group(['prefix' => 'home', 'namespace' => 'Admin'], function() {
Route::get('/page1/{id}', 'PagesController@index')
Route::get('/page1/{id}','PagesController@getname')
});
但是当我访问我的页面1时,它表示未定义的变量页面1
所以基本上return view('pages.page1')->with(['test'=> $output]);
中有两个函数,它们都返回到详细信息页面
答案 0 :(得分:0)
两个相同的网址无法指向不同的功能,除非它们具有不同的 http请求 。例如:GET,POST,PUT等。
在您的情况下,每次访问网址时都会触发PagesController@index
,因为它位于PagesController@getname
之上。